Module: RoleStrategy::Mongoid::OneRole::Implementation
Instance Method Summary
collapse
#add_roles, #remove_roles, #roles_list
#get_role, #get_roles, #set_role, #set_roles
Instance Method Details
#new_role(role) ⇒ Object
41
42
43
|
# File 'lib/roles_mongoid/strategy/single/one_role.rb', line 41
def new_role role
role_class.find_role( role)
end
|
#new_roles(*roles) ⇒ Object
45
46
47
|
# File 'lib/roles_mongoid/strategy/single/one_role.rb', line 45
def new_roles *roles
new_role roles.flatten.first
end
|
#present_roles(*roles) ⇒ Object
49
50
51
|
# File 'lib/roles_mongoid/strategy/single/one_role.rb', line 49
def present_roles *roles
roles.map{|role| role}
end
|
#select_valid_roles(*role_names) ⇒ Object
57
58
59
60
|
# File 'lib/roles_mongoid/strategy/single/one_role.rb', line 57
def select_valid_roles *role_names
role_names = role_names.flat_uniq.select{|role| valid_role? role }
has_role_class? ? role_class.find_roles(role_names).to_a : role_names
end
|
#set_empty_role ⇒ Object
53
54
55
|
# File 'lib/roles_mongoid/strategy/single/one_role.rb', line 53
def set_empty_role
self.send("#{role_attribute}=", nil)
end
|