Sha256: e1440ed5e810d583c51fd47f07c13999d65197fbc3fe4beb0747de80a6f4ca3a
Contents?: true
Size: 701 Bytes
Versions: 4
Compression:
Stored size: 701 Bytes
Contents
require 'dry/logic/evaluator' module Dry module Logic class Rule::Key < Rule::Value attr_reader :name, :evaluator def self.new(predicate, options) name = options.fetch(:name) super(predicate, evaluator: evaluator(options), name: name) end def self.evaluator(options) Evaluator::Key.new(options.fetch(:name)) end def initialize(predicate, options) super @name = options[:name] @evaluator = options[:evaluator] end def evaluate(input) evaluator[input] end def type :key end def to_ast [type, [name, predicate.to_ast]] end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
dry-logic-0.2.3 | lib/dry/logic/rule/key.rb |
dry-logic-0.2.2 | lib/dry/logic/rule/key.rb |
dry-logic-0.2.1 | lib/dry/logic/rule/key.rb |
dry-logic-0.2.0 | lib/dry/logic/rule/key.rb |