Module: RoleStrategy::DataMapper::AdminFlag::Implementation
Instance Method Summary
collapse
#add_roles, #remove_roles, #roles_list
#get_roles, #select_valid_roles, #set_role
Instance Method Details
#get_role ⇒ Object
48
49
50
|
# File 'lib/roles_data_mapper/strategy/single/admin_flag.rb', line 48
def get_role
self.send(role_attribute) ? strategy_class.admin_role_key : strategy_class.default_role_key
end
|
#has_roles?(*roles_names) ⇒ Boolean
37
38
39
40
|
# File 'lib/roles_data_mapper/strategy/single/admin_flag.rb', line 37
def has_roles?(*roles_names)
compare_roles = (roles_names.flat_uniq)
(roles_list & compare_roles).not.empty?
end
|
#new_role(role) ⇒ Object
42
43
44
45
46
|
# File 'lib/roles_data_mapper/strategy/single/admin_flag.rb', line 42
def new_role role
role = role.kind_of?(Array) ? role.flatten.first : role
role.to_sym
end
|
#present_roles(*roles) ⇒ Object
52
53
54
|
# File 'lib/roles_data_mapper/strategy/single/admin_flag.rb', line 52
def present_roles *roles
roles = roles.flat_uniq
end
|
#set_empty_role ⇒ Object
56
57
58
|
# File 'lib/roles_data_mapper/strategy/single/admin_flag.rb', line 56
def set_empty_role
self.send("#{role_attribute}=", :guest)
end
|