Class: AccessRoles::RoleSetQuery Private

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/access_roles/role_set_query.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

RoleSet query interface

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(role_set) ⇒ RoleSetQuery

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of RoleSetQuery


12
13
14
# File 'lib/access_roles/role_set_query.rb', line 12

def initialize(role_set)
  @role_set = role_set
end

Instance Attribute Details

#role_setObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


10
11
12
# File 'lib/access_roles/role_set_query.rb', line 10

def role_set
  @role_set
end

Instance Method Details

#agent(a) ⇒ Object Also known as: group

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


37
38
39
# File 'lib/access_roles/role_set_query.rb', line 37

def agent(a)
  where(agent: a)
end

#agentsArray

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return the list of agents for the Roles matching the criteria.


53
54
55
# File 'lib/access_roles/role_set_query.rb', line 53

def agents
  map { |role| role.agent.first }
end

#criteriaObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


16
17
18
# File 'lib/access_roles/role_set_query.rb', line 16

def criteria
  @criteria ||= {}
end

#detachObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


63
64
65
# File 'lib/access_roles/role_set_query.rb', line 63

def detach
  DetachedRoleSet.new(self)
end

#each(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


47
48
49
# File 'lib/access_roles/role_set_query.rb', line 47

def each(&block)
  role_set.select { |role| matches_all?(role) }.each(&block)
end

#in_policy_scopeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


29
30
31
# File 'lib/access_roles/role_set_query.rb', line 29

def in_policy_scope
  scope(Roles::POLICY_SCOPE)
end

#in_resource_scopeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


33
34
35
# File 'lib/access_roles/role_set_query.rb', line 33

def in_resource_scope
  scope(Roles::RESOURCE_SCOPE)
end

#permissionsArray<Symbol>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return a list of the permissions granted to the Roles matching the criteria.


59
60
61
# File 'lib/access_roles/role_set_query.rb', line 59

def permissions
  map(&:permissions).flatten.uniq
end

#role_type(r) ⇒ Object Also known as: type

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


42
43
44
# File 'lib/access_roles/role_set_query.rb', line 42

def role_type(r)
  where(role_type: r)
end

#scope(s) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


25
26
27
# File 'lib/access_roles/role_set_query.rb', line 25

def scope(s)
  where(scope: s)
end

#where(conditions = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


20
21
22
23
# File 'lib/access_roles/role_set_query.rb', line 20

def where(conditions={})
  criteria.merge!(conditions)
  self
end