lib/dry/logic/rule/result.rb in dry-logic-0.1.3 vs lib/dry/logic/rule/result.rb in dry-logic-0.1.4

- old
+ new

@@ -1,20 +1,29 @@ module Dry module Logic class Rule::Result < Rule def call(input) - result = input[name] - result_input = result.input + result = if name.is_a?(Hash) + parent, _ = name.to_a.flatten + input[parent] + else + input[name] + end if result.success? - Result::Wrapped.new(input, predicate.(result_input), self) + Result::Wrapped.new(input, predicate.(evaluate_input(input)), self) else result end end def evaluate_input(result) - result[name].input + if name.is_a?(Hash) + parent, child = name.to_a.flatten + result[parent].input[child] + else + result[name].input + end end def type :res end