Module: AuthAssistant::RoleStrategy::AdminField

Defined in:
lib/auth_assistant/role_strategies/admin_field.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



32
33
34
# File 'lib/auth_assistant/role_strategies/admin_field.rb', line 32

def self.included(base)  
  base.extend(ClassMethods)
end

Instance Method Details

#roleObject



18
19
20
# File 'lib/auth_assistant/role_strategies/admin_field.rb', line 18

def role
  admin == true ? 'admin' : 'default' 
end

#role=(role) ⇒ Object



14
15
16
# File 'lib/auth_assistant/role_strategies/admin_field.rb', line 14

def role=(role)
  self.roles = [role]
end

#role?(_role) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/auth_assistant/role_strategies/admin_field.rb', line 22

def role?(_role)
  role == _role.to_s
end

#rolesObject



10
11
12
# File 'lib/auth_assistant/role_strategies/admin_field.rb', line 10

def roles
  [role]
end

#roles=(*roles) ⇒ Object



5
6
7
8
# File 'lib/auth_assistant/role_strategies/admin_field.rb', line 5

def roles=(*roles)
  new_role = roles.first.to_s
  self.admin = new_role == 'admin'
end