lib/dry/logic/rule/set.rb in dry-logic-0.1.4 vs lib/dry/logic/rule/set.rb in dry-logic-0.2.0
- old
+ new
@@ -1,22 +1,23 @@
module Dry
module Logic
- class Rule::Set < Rule
- def call(input)
- Logic.Result(input, predicate.map { |rule| rule.(input) }, self)
- end
+ class Rule::Set < Rule::Value
+ alias_method :rules, :predicate
def type
:set
end
+ def apply(input)
+ rules.map { |rule| rule.(input) }
+ end
+
def at(*args)
- self.class.new(name, predicate.values_at(*args))
+ new(rules.values_at(*args))
end
- def to_ary
- [type, [name, predicate.map(&:to_ary)]]
+ def to_ast
+ [type, rules.map { |rule| rule.to_ast }]
end
- alias_method :to_a, :to_ary
end
end
end