Sha256: 13bbd7f761d2e8e3e8f44ebe0db954eacc41152d3e65104bba392a0bde88af4e

Contents?: true

Size: 612 Bytes

Versions: 16

Compression:

Stored size: 612 Bytes

Contents

require_relative 'schema_types'

module Jimmy
  class Combination < Array
    include SchemaCreation::Referencing

    attr_reader :condition, :schema

    # @param [Symbol] condition One of :one, :all, or :any
    def initialize(condition, schema)
      @condition = condition
      @schema = schema
    end

    def domain
      schema.domain
    end

    def evaluate(types_proc)
      instance_exec &types_proc
    end

    def compile
      data.merge "#{condition}Of" => map(&:compile)
    end

    def data
      @data ||= {}
    end

    SchemaCreation.apply_to(self) { |schema| push schema }

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
jimmy-0.5.5 lib/jimmy/combination.rb
jimmy-0.5.4 lib/jimmy/combination.rb
jimmy-0.5.3 lib/jimmy/combination.rb
jimmy-0.5.2 lib/jimmy/combination.rb
jimmy-0.5.1 lib/jimmy/combination.rb
jimmy-0.5.0 lib/jimmy/combination.rb
jimmy-0.4.8 lib/jimmy/combination.rb
jimmy-0.4.7 lib/jimmy/combination.rb
jimmy-0.4.6 lib/jimmy/combination.rb
jimmy-0.4.5 lib/jimmy/combination.rb
jimmy-0.4.4 lib/jimmy/combination.rb
jimmy-0.4.3 lib/jimmy/combination.rb
jimmy-0.4.2 lib/jimmy/combination.rb
jimmy-0.4.1 lib/jimmy/combination.rb
jimmy-0.4 lib/jimmy/combination.rb
jimmy-0.3.4 lib/jimmy/combination.rb