Module: RoleStrategy::Mongoid::RoleStrings::Implementation
- Includes:
- Mongoid::Roles::Strategy::Multi
- Defined in:
- lib/roles_mongoid/strategy/multi/role_strings.rb
Instance Method Summary collapse
- #new_roles(*roles) ⇒ Object
- #present_roles(roles_names) ⇒ Object
- #select_valid_roles(*roles) ⇒ Object
- #set_empty_roles ⇒ Object
Instance Method Details
#new_roles(*roles) ⇒ Object
34 35 36 |
# File 'lib/roles_mongoid/strategy/multi/role_strings.rb', line 34 def new_roles *roles ::Set.new select_valid_roles(roles) end |
#present_roles(roles_names) ⇒ Object
46 47 48 |
# File 'lib/roles_mongoid/strategy/multi/role_strings.rb', line 46 def present_roles roles_names roles_names.to_a end |
#select_valid_roles(*roles) ⇒ Object
38 39 40 |
# File 'lib/roles_mongoid/strategy/multi/role_strings.rb', line 38 def select_valid_roles *roles roles.flat_uniq.select{|role| valid_role? role }.map(&:to_sym) end |
#set_empty_roles ⇒ Object
42 43 44 |
# File 'lib/roles_mongoid/strategy/multi/role_strings.rb', line 42 def set_empty_roles self.send("#{role_attribute}=", []) end |