Sha256: 60ca1ce3b69c86031dc75764bc30064d7d556811378318028bdcdc47f9b1dc0b
Contents?: true
Size: 726 Bytes
Versions: 1
Compression:
Stored size: 726 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) eval = options.fetch(:evaluator, evaluator(name)) super(predicate, evaluator: eval, name: name) end def self.evaluator(name) Evaluator::Key.new(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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry-logic-0.3.0 | lib/dry/logic/rule/key.rb |