From 77e2d8ab317da7cbc3c86beca6d4bd2a4cae4b19 Mon Sep 17 00:00:00 2001 From: sampatbadhe Date: Sun, 25 Dec 2022 16:50:01 +0530 Subject: [PATCH] Fixes #158 - fix issue for respond_to method returns false for custom model method names starts with is_ and ends with ? --- lib/rolify/role.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/rolify/role.rb b/lib/rolify/role.rb index 34f6f13a..733aefba 100644 --- a/lib/rolify/role.rb +++ b/lib/rolify/role.rb @@ -101,12 +101,12 @@ def method_missing(method, *args, &block) def respond_to?(method, include_private = false) if Rolify.dynamic_shortcuts && (method.to_s.match(/^is_(\w+)_of[?]$/) || method.to_s.match(/^is_(\w+)[?]$/)) query = self.class.role_class.where(:name => $1) - query = self.class.adapter.exists?(query, :resource_type) if method.to_s.match(/^is_(\w+)_of[?]$/) - return true if query.count > 0 - false - else - super + if query + query = self.class.adapter.exists?(query, :resource_type) if method.to_s.match(/^is_(\w+)_of[?]$/) + return query.count > 0 + end end + super end end end