Class: Ddr::Auth::Roles::RoleSetQuery Private

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ddr/auth/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.



13
14
15
# File 'lib/ddr/auth/roles/role_set_query.rb', line 13

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.



11
12
13
# File 'lib/ddr/auth/roles/role_set_query.rb', line 11

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.



38
39
40
# File 'lib/ddr/auth/roles/role_set_query.rb', line 38

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.

Returns:

  • (Array)

    the agents



54
55
56
# File 'lib/ddr/auth/roles/role_set_query.rb', line 54

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.



17
18
19
# File 'lib/ddr/auth/roles/role_set_query.rb', line 17

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.



64
65
66
# File 'lib/ddr/auth/roles/role_set_query.rb', line 64

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.



48
49
50
# File 'lib/ddr/auth/roles/role_set_query.rb', line 48

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.



30
31
32
# File 'lib/ddr/auth/roles/role_set_query.rb', line 30

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.



34
35
36
# File 'lib/ddr/auth/roles/role_set_query.rb', line 34

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.

Returns:

  • (Array<Symbol>)

    the permissions



60
61
62
# File 'lib/ddr/auth/roles/role_set_query.rb', line 60

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.



43
44
45
# File 'lib/ddr/auth/roles/role_set_query.rb', line 43

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.



26
27
28
# File 'lib/ddr/auth/roles/role_set_query.rb', line 26

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.



21
22
23
24
# File 'lib/ddr/auth/roles/role_set_query.rb', line 21

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