Class: Checkpoint::DB::Query::CR

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

Overview

A query object based on credentials and resources.

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

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(credentials, resources, scope: Grant) ⇒ CR

Returns a new instance of CR.



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

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

Instance Attribute Details

#credentialsObject (readonly)

Returns the value of attribute credentials.



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

def credentials
  @credentials
end

#resourcesObject (readonly)

Returns the value of attribute resources.



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

def resources
  @resources
end

Instance Method Details

#conditionsObject



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

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

#parametersObject



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

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