Module: RoleStrategy::Mongoid::RoleStrings::Implementation

Includes:
Roles::Mongoid::Strategy::Multi
Defined in:
lib/roles_mongoid/strategy/multi/role_strings.rb

Instance Method Summary collapse

Methods included from Roles::Mongoid::Strategy::Multi

#add_roles, #remove_roles, #roles, #roles=, #roles_list

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_rolesObject



42
43
44
# File 'lib/roles_mongoid/strategy/multi/role_strings.rb', line 42

def set_empty_roles
  self.send("#{role_attribute}=", [])
end