Sha256: 2f305c53c5de70e961f77fe22e98256d8665b40d81df419f0e1c01748498b587
Contents?: true
Size: 776 Bytes
Versions: 1
Compression:
Stored size: 776 Bytes
Contents
# frozen_string_literal: true module Speculation using NamespacedSymbols.refine(self) # @private class MergeSpec < SpecImpl S = Speculation def initialize(preds) @preds = preds end def conform(x) ms = @preds.map { |pred| S.dt(pred, x) } if ms.any?(&S.method(:invalid?)) :invalid.ns(S) else ms.reduce(&:merge) end end def explain(path, via, inn, x) @preds. flat_map { |pred| S.explain1(pred, path, via, inn, x) }. compact end def gen(overrides, path, rmap) return @gen if @gen gens = @preds. map { |pred| S.gensub(pred, overrides, path, rmap) } ->(r) do gens.map { |gen| gen.call(r) }.reduce(&:merge) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
speculation-0.1.0 | lib/speculation/spec_impl/merge_spec.rb |