Module: SimpleRoles::Many::RolesMethods

Defined in:
lib/simple_roles/many/roles_methods.rb

Defined Under Namespace

Modules: DynamicMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
# File 'lib/simple_roles/many/roles_methods.rb', line 5

def included base
  base.class_eval %{
    extend SimpleRoles::Many::RolesMethods::DynamicMethods
  }
end

Instance Method Details

#add_roles(*rolez) ⇒ Object Also known as: add_role



70
71
72
# File 'lib/simple_roles/many/roles_methods.rb', line 70

def add_roles *rolez
  self.roles = roles + rolez
end

#has_any_role?(*rolez) ⇒ Boolean

Returns:

  • (Boolean)


62
63
64
65
66
67
68
# File 'lib/simple_roles/many/roles_methods.rb', line 62

def has_any_role? *rolez
  rolez.flatten!

  rolez.any? do |role|
    roles.include? role
  end
end

#has_roles?(*rolez) ⇒ Boolean Also known as: has_role?

Returns:

  • (Boolean)


52
53
54
55
56
57
58
# File 'lib/simple_roles/many/roles_methods.rb', line 52

def has_roles? *rolez
  rolez.flatten!

  rolez.all? do |role|
    roles.include? role
  end
end

#mass_assignment_authorizer(*args) ⇒ Object



48
49
50
# File 'lib/simple_roles/many/roles_methods.rb', line 48

def mass_assignment_authorizer *args
  super.empty? ? super : (super + [:roles])
end

#remove_roles(*rolez) ⇒ Object Also known as: remove_role



76
77
78
# File 'lib/simple_roles/many/roles_methods.rb', line 76

def remove_roles *rolez
  self.roles = roles - rolez
end

#roles_listObject



44
45
46
# File 'lib/simple_roles/many/roles_methods.rb', line 44

def roles_list
  roles
end

#set_role(r) ⇒ Object



82
83
84
# File 'lib/simple_roles/many/roles_methods.rb', line 82

def set_role r
  self.roles = r
end