Class: Dry::Logic::Result::Each
- Inherits:
-
Multi
- Object
- Dry::Logic::Result
- Multi
- Dry::Logic::Result::Each
- Defined in:
- lib/dry/logic/result/each.rb
Instance Attribute Summary
Attributes inherited from Dry::Logic::Result
#input, #response, #rule, #success
Instance Method Summary collapse
Methods inherited from Dry::Logic::Result
[], #[], #failure?, #initialize, #name, #negated
Constructor Details
This class inherits a constructor from Dry::Logic::Result
Instance Method Details
#failures ⇒ Object
13 14 15 16 17 |
# File 'lib/dry/logic/result/each.rb', line 13 def failures response.each_with_object({}) { |(idx, res), hash| hash[idx] = res if res.failure? } end |
#success? ⇒ Boolean
9 10 11 |
# File 'lib/dry/logic/result/each.rb', line 9 def success? response.values.all?(&:success?) end |
#to_ast ⇒ Object
4 5 6 7 |
# File 'lib/dry/logic/result/each.rb', line 4 def to_ast failed_rules = failures.map { |idx, el| [:el, [idx, el.to_ast]] } [:result, [rule.evaluate(input), [:each, failed_rules]]] end |