Sha256: d84b970b7c367d74a2b506352a15442c9e13d9c777f7312cb0d8e62044644eb2

Contents?: true

Size: 493 Bytes

Versions: 1

Compression:

Stored size: 493 Bytes

Contents

module Dry
  module Logic
    class Rule::Set < Rule::Value
      alias_method :rules, :predicate

      def type
        :set
      end

      def arity
        -1
      end

      def apply(input)
        rules.map { |rule| rule.(input) }
      end

      def curry(*args)
        new(rules.map { |r| r.curry(*args) })
      end

      def at(*args)
        new(rules.values_at(*args))
      end

      def to_ast
        [type, rules.map { |rule| rule.to_ast }]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry-logic-0.3.0 lib/dry/logic/rule/set.rb