Sha256: 43f65ff8a2ed75ae81198787539eb62dba2021216102c53bbb6dbfa688e8ef2c

Contents?: true

Size: 858 Bytes

Versions: 8

Compression:

Stored size: 858 Bytes

Contents

module Lurker
  module Json
    module Tuple
      module InstanceMethods
        def merge!(schema)
          return if exists?(schema)

          @schema[tuple_key] << @parser.typed.parse_property(
            parent_property, schema)
        end

        def replace!(schema)
          raise NotImplementedError
        end

        def exists?(schema)
          @schema[tuple_key].any? { |schm| schm.eql?(schema) }
        end

        private

        def parse_schema(schema)
          @schema = {}
          initialize_properties

          schema = schema.dup
          @schema[tuple_key] = (schema.delete(tuple_key) || schema).map do |payload|
            @parser.typed.parse_property(parent_property, payload)
          end
        end

        def initialize_properties
          @schema[tuple_key] ||= []
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
lurker-1.0.0 lib/lurker/json/schema/tuple.rb
lurker-0.6.12 lib/lurker/json/schema/tuple.rb
lurker-0.6.11 lib/lurker/json/schema/tuple.rb
lurker-0.6.10 lib/lurker/json/schema/tuple.rb
lurker-0.6.9 lib/lurker/json/schema/tuple.rb
lurker-0.6.8 lib/lurker/json/schema/tuple.rb
lurker-0.6.7 lib/lurker/json/schema/tuple.rb
lurker-0.6.6 lib/lurker/json/schema/tuple.rb