Sha256: 1578f0356dfb03b6755d99cc2eea09123317e8328ffd70c7692635532ddb2726
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true module Speculation using Speculation::NamespacedSymbols.refine(self) using Conj # @private class Spec < SpecImpl S = Speculation def initialize(predicate, should_conform) @predicate = predicate @should_conform = should_conform end def conform(value) ret = case @predicate when Set then @predicate.include?(value) when Regexp, Module then @predicate === value else @predicate.call(value) end if @should_conform ret else ret ? value : :invalid.ns end end def explain(path, via, inn, value) if S.invalid?(S.dt(@predicate, value)) [{ :path => path, :val => value, :via => via, :in => inn, :pred => @predicate }] end end def gen(_, _, _) if @gen @gen else Gen.gen_for_pred(@predicate) end end def inspect "#{self.class}(#{@name || @predicate.inspect})" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
speculation-0.1.0 | lib/speculation/spec_impl/spec.rb |