Module: Mongoid::Fromage
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/mongoid/fromage.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #add_role(*roles) ⇒ Object
- #add_role!(*args) ⇒ Object
- #has_role?(role) ⇒ Boolean
- #has_roles?(*args) ⇒ Boolean
- #remove_role(role) ⇒ Object
- #remove_role!(role) ⇒ Object
Instance Method Details
#add_role(*roles) ⇒ Object
19 20 21 |
# File 'lib/mongoid/fromage.rb', line 19 def add_role(*roles) self.roles += roles end |
#add_role!(*args) ⇒ Object
23 24 25 26 |
# File 'lib/mongoid/fromage.rb', line 23 def add_role!(*args) add_role(*args) save end |
#has_role?(role) ⇒ Boolean
37 38 39 |
# File 'lib/mongoid/fromage.rb', line 37 def has_role?(role) roles.include? role end |
#has_roles?(*args) ⇒ Boolean
41 42 43 |
# File 'lib/mongoid/fromage.rb', line 41 def has_roles?(*args) args.all? {|role| has_role?(role) } end |
#remove_role(role) ⇒ Object
28 29 30 |
# File 'lib/mongoid/fromage.rb', line 28 def remove_role(role) self.roles = self.roles.delete(role) end |
#remove_role!(role) ⇒ Object
32 33 34 35 |
# File 'lib/mongoid/fromage.rb', line 32 def remove_role!(role) remove_role(role) save end |