Module: Rubee::Authorizable::InstanceMethods
- Defined in:
- lib/rubee/controllers/extensions/authorizable.rb
Instance Method Summary collapse
Instance Method Details
#authorized?(role, model: nil, role_field: :role) ⇒ Boolean
9 10 11 12 13 14 15 16 |
# File 'lib/rubee/controllers/extensions/authorizable.rb', line 9 def (role, model: nil, role_field: :role) return false unless authentificated? user = authentificated_user(user_model: model) return false unless user return false unless model.const_get(:ROLES).keys.map(&:to_sym).include?(role.to_sym) model.const_get(:ROLES).key(user.send(role_field)).to_sym == role.to_sym end |