Module: RoleStrategy::ActiveRecord::AdminFlag::Implementation
Instance Method Summary
collapse
#add_roles, #remove_roles, #roles_list
#has_any_roles?, #has_no_roles?, #remove_all_roles!, #select_valid_roles, #set_default_role, #set_role
Instance Method Details
#get_role ⇒ Object
36
37
38
|
# File 'lib/roles_active_record/strategy/single/admin_flag.rb', line 36
def get_role
self.send(role_attribute) ? strategy_class.admin_role_key : strategy_class.default_role_key
end
|
#new_role(role) ⇒ Object
31
32
33
34
|
# File 'lib/roles_active_record/strategy/single/admin_flag.rb', line 31
def new_role role
role = role.kind_of?(Array) ? role.flatten.first : role
role.admin?
end
|
#present_roles(*roles) ⇒ Object
40
41
42
43
|
# File 'lib/roles_active_record/strategy/single/admin_flag.rb', line 40
def present_roles *roles
roles = roles.flat_uniq
roles.map{|role| role ? :admin : :guest}
end
|
#set_empty_role ⇒ Object
45
46
47
|
# File 'lib/roles_active_record/strategy/single/admin_flag.rb', line 45
def set_empty_role
self.send("#{role_attribute}=", false)
end
|