Skip to content

Commit

Permalink
Fixes RolifyCommunity#158 - fix issue for respond_to method returns f…
Browse files Browse the repository at this point in the history
…alse for custom model method names starts with is_ and ends with ?
  • Loading branch information
sampatbadhe committed Dec 25, 2022
1 parent 584d329 commit 77e2d8a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/rolify/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 77e2d8a

Please sign in to comment.