Module: RoleStrategy::DataMapper::AdminFlag::Implementation

Includes:
Roles::DataMapper::Strategy::Single
Defined in:
lib/roles_data_mapper/strategy/single/admin_flag.rb

Instance Method Summary collapse

Methods included from Roles::DataMapper::Strategy::Single

#add_roles, #remove_roles, #roles_list

Methods included from Roles::DataMapper::Strategy::Shared

#get_roles, #select_valid_roles, #set_role

Instance Method Details

#get_roleObject



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

Returns:

  • (Boolean)


37
38
39
40
# File 'lib/roles_data_mapper/strategy/single/admin_flag.rb', line 37

def has_roles?(*roles_names)
  compare_roles = extract_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
  # role.admin?
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_roleObject



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