Class: SexyJSONSchemas::SchemaDefinition

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/sexy_json_schemas/schema_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options) ⇒ SchemaDefinition

Returns a new instance of SchemaDefinition.



10
11
12
13
14
# File 'lib/sexy_json_schemas/schema_definition.rb', line 10

def initialize(name, options)
  @name        = name
  @root_element = options.fetch(:root_element, name)
  @core_object = Properties::Object.new(name, options)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/sexy_json_schemas/schema_definition.rb', line 5

def name
  @name
end

Instance Method Details

#as_jsonObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/sexy_json_schemas/schema_definition.rb', line 16

def as_json
  json = @core_object.as_json

  if root_element?
    json = wrap_in_root(json)
  end

  json['name'] = name

  json
end