Class: Checkpoint::DB::Query::AC

Inherits:
CartesianSelect show all
Defined in:
lib/checkpoint/db/query/ac.rb

Overview

A query object based on agents and credentials.

This query finds grants for any supplied agents, for any supplied credentials. Its primary purpose is to find which resources for which an agent has been granted a given credential.

It can take single items or arrays and converts them all to their tokens for query purposes.

Instance Attribute Summary collapse

Attributes inherited from CartesianSelect

#scope

Instance Method Summary collapse

Methods inherited from CartesianSelect

#all, #delete, #first, #query

Constructor Details

#initialize(agents, credentials, scope: Grant) ⇒ AC

Returns a new instance of AC.



16
17
18
19
20
# File 'lib/checkpoint/db/query/ac.rb', line 16

def initialize(agents, credentials, scope: Grant)
  super(scope: scope)
  @agents      = tokenize(agents)
  @credentials = tokenize(credentials)
end

Instance Attribute Details

#agentsObject (readonly)

Returns the value of attribute agents.



14
15
16
# File 'lib/checkpoint/db/query/ac.rb', line 14

def agents
  @agents
end

#credentialsObject (readonly)

Returns the value of attribute credentials.



14
15
16
# File 'lib/checkpoint/db/query/ac.rb', line 14

def credentials
  @credentials
end

Instance Method Details

#conditionsObject



22
23
24
25
26
27
# File 'lib/checkpoint/db/query/ac.rb', line 22

def conditions
  super.merge(
    agent_token:      agent_params.placeholders,
    credential_token: credential_params.placeholders
  )
end

#parametersObject



29
30
31
32
33
34
# File 'lib/checkpoint/db/query/ac.rb', line 29

def parameters
  super.merge(Hash[
    agent_params.values +
    credential_params.values
  ])
end