Sha256: e4b2607eb5ba36c1d8161de182e95b7168e49e713a1994b8c90e92cdb21f954b
Contents?: true
Size: 656 Bytes
Versions: 5
Compression:
Stored size: 656 Bytes
Contents
module Dry module Logic def self.Predicate(block) case block when Method then Predicate.new(block.name, &block) else raise ArgumentError, 'predicate needs an :id' end end class Predicate include Dry::Equalizer(:id) attr_reader :id, :args, :fn def initialize(id, *args, &block) @id = id @fn = block @args = args end def call(*args) fn.(*args) end def curry(*args) self.class.new(id, *args, &fn.curry.(*args)) end def to_ary [:predicate, [id, args]] end alias_method :to_a, :to_ary end end end
Version data entries
5 entries across 5 versions & 1 rubygems