Class: KCV::AgentResolver
- Inherits:
-
Checkpoint::Agent::Resolver
- Object
- Checkpoint::Agent::Resolver
- KCV::AgentResolver
- Defined in:
- lib/kcv/agent_resolver.rb
Overview
Base AgentResolver to integrate Keycard and Checkpoint.
This resolver depends on the actor having the ‘#identity` method, from which all attributes are extracted and delivered as agents, as converted by the `agent_factory`.
Instance Method Summary collapse
- #agents_for(attribute, values) ⇒ Object
-
#initialize(agent_factory: Checkpoint::Agent) ⇒ AgentResolver
constructor
A new instance of AgentResolver.
- #resolve(actor) ⇒ Object
Constructor Details
#initialize(agent_factory: Checkpoint::Agent) ⇒ AgentResolver
Returns a new instance of AgentResolver.
13 14 15 |
# File 'lib/kcv/agent_resolver.rb', line 13 def initialize(agent_factory: Checkpoint::Agent) @agent_factory = agent_factory end |
Instance Method Details
#agents_for(attribute, values) ⇒ Object
21 22 23 24 25 |
# File 'lib/kcv/agent_resolver.rb', line 21 def agents_for(attribute, values) [values].flatten.map do |value| agent_factory.from(OpenStruct.new(agent_type: attribute, agent_id: value)) end end |
#resolve(actor) ⇒ Object
17 18 19 |
# File 'lib/kcv/agent_resolver.rb', line 17 def resolve(actor) super + actor.identity.map { |k, v| agents_for(k, v) }.flatten end |