Class: Trailblazer::Operation::Policy::Eval
- Inherits:
-
Object
- Object
- Trailblazer::Operation::Policy::Eval
- Defined in:
- lib/trailblazer/operation/policy.rb
Overview
Step: This generically ‘call`s a policy and then pushes its result to `options`. You can use any callable object as a policy with this step.
Instance Method Summary collapse
- #call(input, options) ⇒ Object
-
#initialize(name: nil, path: nil) ⇒ Eval
constructor
A new instance of Eval.
Constructor Details
#initialize(name: nil, path: nil) ⇒ Eval
Returns a new instance of Eval.
6 7 8 9 |
# File 'lib/trailblazer/operation/policy.rb', line 6 def initialize(name:nil, path:nil) @name = name @path = path end |
Instance Method Details
#call(input, options) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/trailblazer/operation/policy.rb', line 11 def call(input, ) condition = [@path] # this allows dependency injection. result = condition.(input, ) ["policy.#{@name}"] = result["policy"] # assign the policy as a skill. ["result.policy.#{@name}"] = result # flow control result.success? # since we & this, it's only executed OnRight and the return boolean decides the direction, input is passed straight through. end |