Module: RoleStrategy::MongoMapper::RoleString::Implementation

Includes:
Roles::MongoMapper::Strategy::Single
Defined in:
lib/roles_mongo_mapper/strategy/single/role_string.rb

Instance Method Summary collapse

Methods included from Roles::MongoMapper::Strategy::Single

#add_roles, #remove_roles, #roles_list

Methods included from Roles::MongoMapper::Strategy::Shared

#get_role, #get_roles, #select_valid_roles, #set_role, #set_roles

Instance Method Details

#new_role(role) ⇒ Object



27
28
29
30
# File 'lib/roles_mongo_mapper/strategy/single/role_string.rb', line 27

def new_role role
  role = role.kind_of?(Array) ? role.first : role
  role.to_s
end

#new_roles(*roles) ⇒ Object



32
33
34
# File 'lib/roles_mongo_mapper/strategy/single/role_string.rb', line 32

def new_roles *roles
  new_role roles.flatten.first
end

#present_role(role) ⇒ Object Also known as: present_roles



36
37
38
39
# File 'lib/roles_mongo_mapper/strategy/single/role_string.rb', line 36

def present_role role
  return role if role.kind_of? Array
  role.split(',').map(&:to_sym)
end

#set_empty_roleObject



41
42
43
# File 'lib/roles_mongo_mapper/strategy/single/role_string.rb', line 41

def set_empty_role
  self.send("#{role_attribute}=", "")
end