Sha256: f0d9b8416df8ba4cea79c26cee4cc18a4c5d3c46414c6be9344db3387d0b922a
Contents?: true
Size: 758 Bytes
Versions: 1
Compression:
Stored size: 758 Bytes
Contents
# frozen_string_literal: true module Speculation # @private class MergeSpec < Spec include NamespacedSymbols 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?)) S::INVALID 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.3.0 | lib/speculation/spec/merge_spec.rb |