Module: SimpleRoles::One::RolesMethods

Includes:
Persistence
Defined in:
lib/simple_roles/one/roles_methods.rb

Defined Under Namespace

Modules: DynamicMethods

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Persistence

#role, #role=

Class Method Details

.included(base) ⇒ Object



7
8
9
# File 'lib/simple_roles/one/roles_methods.rb', line 7

def included base
  base.extend DynamicMethods
end

Instance Method Details

#has_any_role?(*rolez) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
# File 'lib/simple_roles/one/roles_methods.rb', line 22

def has_any_role? *rolez
  rolez.flatten!

  rolez.any? do |r|
    has_role? r
  end
end

#has_role?(r) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/simple_roles/one/roles_methods.rb', line 18

def has_role? r
  role == r
end

#set_role(r) ⇒ Object Also known as: update_role



12
13
14
15
# File 'lib/simple_roles/one/roles_methods.rb', line 12

def set_role r
  self.role= r
  save!
end