Class: Objectify::PolicyChainExecutor

Inherits:
Object
  • Object
show all
Includes:
Instrumentation
Defined in:
lib/objectify/policy_chain_executor.rb

Instance Method Summary collapse

Constructor Details

#initialize(executor, context) ⇒ PolicyChainExecutor

Returns a new instance of PolicyChainExecutor.



7
8
9
10
# File 'lib/objectify/policy_chain_executor.rb', line 7

def initialize(executor, context)
  @executor = executor
  @context  = context
end

Instance Method Details

#call(action) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/objectify/policy_chain_executor.rb', line 12

def call(action)
  action.policies.each do |policy|
    if !@executor.call(policy, :policy)
      responder = @context.policy_responder(policy)
      instrument("policy_chain_halted.objectify", :policy    => policy,
                                                  :responder => responder)
      @executor.call(responder, :responder)

      return false
    end
  end

  true
end