Module: ActiveRecord::Aggregations::HasRoles::InstanceMethods
- Defined in:
- lib/active_record/aggregations/has_roles.rb
Instance Method Summary collapse
-
#is?(*role_names) ⇒ Boolean
returns true - when user has administrator role - when user has one of the supplied roles.
- #is_not?(*role_names) ⇒ Boolean
Instance Method Details
#is?(*role_names) ⇒ Boolean
returns true
- when user has administrator role
- when user has one of the supplied roles
49 50 51 52 53 |
# File 'lib/active_record/aggregations/has_roles.rb', line 49 def is?(*role_names) roles = Rails.cache.fetch("/#{self.class.to_s.tableize}/#{id}/roles") { self.roles.map } return true if roles.include?(Role[:administrator]) Array(role_names).any? { |name| roles.include?(Role[name]) } end |
#is_not?(*role_names) ⇒ Boolean
55 56 57 |
# File 'lib/active_record/aggregations/has_roles.rb', line 55 def is_not?(*role_names) not is?(*role_names) end |