Class: Lurker::Json::Object

Inherits:
Schema
  • Object
show all
Defined in:
lib/lurker/json/schema/object.rb

Constant Summary

Constants inherited from Schema

Schema::EXTENSIONS, Schema::REQUEST_PARAMETERS, Schema::RESPONSE_CODES, Schema::RESPONSE_PARAMETERS

Instance Attribute Summary

Attributes inherited from Schema

#parent_property, #parent_schema, #root_schema, #uri

Instance Method Summary collapse

Methods inherited from Schema

#documentation, #documentation_uri, #initialize, #method_missing, #reorder!, #respond_to_missing?, #root?, #to_hash, #to_json, #to_yaml

Methods included from Concerns::Validatable

#to_validation_schema, #validate

Constructor Details

This class inherits a constructor from Lurker::Json::Schema

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Lurker::Json::Schema

Instance Method Details

#merge!(schema) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/lurker/json/schema/object.rb', line 4

def merge!(schema)
  unless schema.is_a?(Hash)
    raise TypeError, "Unable to merge #{schema.class} into JSON object"
  end

  schema.each do |property, property_schema|
    if @schema[Json::PROPERTIES].key?(property)
      @schema[Json::PROPERTIES][property].merge!(property_schema)
      next
    end

    replace!(property, property_schema)
  end
end

#replace!(property, property_schema) ⇒ Object



19
20
21
22
# File 'lib/lurker/json/schema/object.rb', line 19

def replace!(property, property_schema)
  @schema[Json::PROPERTIES][property] = Lurker::Json::Parser.typed(subschema_options)
    .parse_property(property, property_schema)
end