Method: Rolify::Role#respond_to?

Defined in:
lib/rolify/role.rb

#respond_to?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


101
102
103
104
105
106
107
108
109
110
# File 'lib/rolify/role.rb', line 101

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
  end
end