Sha256: 6c0d25acdbc8a1df3e32420dd5831bd99f848a8b6885e9608e170f0c81358377

Contents?: true

Size: 671 Bytes

Versions: 16

Compression:

Stored size: 671 Bytes

Contents

require 'forwardable'

module Jimmy
  class Definitions
    include SchemaCreation::Referencing
    extend Forwardable
    delegate %i[empty? key? map] => :@values
    
    attr_reader :schema

    def initialize(schema)
      @schema = schema
      @values = {}
    end

    def evaluate(&block)
      instance_exec &block
    end

    def domain
      schema.domain
    end

    def compile
      map { |k, v| [k.to_s, v.compile] }.to_h
    end

    def data
      schema.data
    end

    def [](key)
      @values[key] || (schema.parent && schema.parent.definitions[key])
    end

    SchemaCreation.apply_to(self) { |schema, name| @values[name] = schema }
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

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