Sha256: 6787cb74f73dc00886eb30631e9bbe2bccf933e8c1c41c77fa4b1008d5edab68
Contents?: true
Size: 661 Bytes
Versions: 2
Compression:
Stored size: 661 Bytes
Contents
module Dry module Validation 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dry-validation-0.4.1 | lib/dry/validation/predicate.rb |
dry-validation-0.4.0 | lib/dry/validation/predicate.rb |