Class: Checkpoint::DB::Query::ACR

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

Overview

A query object based on agents, credentials, and resources.

This query mirrors the essence of the Checkpoint semantics; that is, it finds grants for any supplied agents, for any supplied credentials, for any supplied resources.

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, resources, scope: Grant) ⇒ ACR

Returns a new instance of ACR.



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

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

Instance Attribute Details

#agentsObject (readonly)

Returns the value of attribute agents.



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

def agents
  @agents
end

#credentialsObject (readonly)

Returns the value of attribute credentials.



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

def credentials
  @credentials
end

#resourcesObject (readonly)

Returns the value of attribute resources.



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

def resources
  @resources
end

Instance Method Details

#conditionsObject



23
24
25
26
27
28
29
# File 'lib/checkpoint/db/query/acr.rb', line 23

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

#parametersObject



31
32
33
34
35
36
37
# File 'lib/checkpoint/db/query/acr.rb', line 31

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