Class: JsonDataExtractor::SchemaElement
- Inherits:
-
Object
- Object
- JsonDataExtractor::SchemaElement
- Defined in:
- lib/json_data_extractor/schema_element.rb
Overview
parses the input schema element
Instance Attribute Summary collapse
-
#array_type ⇒ Object
readonly
Returns the value of attribute array_type.
-
#default_value ⇒ Object
readonly
Returns the value of attribute default_value.
-
#maps ⇒ Object
readonly
Returns the value of attribute maps.
-
#modifiers ⇒ Object
readonly
Returns the value of attribute modifiers.
-
#nested ⇒ Object
readonly
Returns the value of attribute nested.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #fetch_default_value ⇒ Object
-
#initialize(schema_definition) ⇒ SchemaElement
constructor
A new instance of SchemaElement.
Constructor Details
#initialize(schema_definition) ⇒ SchemaElement
Returns a new instance of SchemaElement.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/json_data_extractor/schema_element.rb', line 8 def initialize(schema_definition) validate_schema_definition(schema_definition) @path = schema_definition[:path] if schema_definition.key?(:path) @default_value = schema_definition[:default] @maps = fetch_maps(schema_definition[:maps] || schema_definition[:map]) @modifiers = fetch_modifiers(schema_definition[:modifiers] || schema_definition[:modifier]) @array_type = schema_definition[:type] == 'array' @nested = schema_definition[:schema] end |
Instance Attribute Details
#array_type ⇒ Object (readonly)
Returns the value of attribute array_type.
6 7 8 |
# File 'lib/json_data_extractor/schema_element.rb', line 6 def array_type @array_type end |
#default_value ⇒ Object (readonly)
Returns the value of attribute default_value.
6 7 8 |
# File 'lib/json_data_extractor/schema_element.rb', line 6 def default_value @default_value end |
#maps ⇒ Object (readonly)
Returns the value of attribute maps.
6 7 8 |
# File 'lib/json_data_extractor/schema_element.rb', line 6 def maps @maps end |
#modifiers ⇒ Object (readonly)
Returns the value of attribute modifiers.
6 7 8 |
# File 'lib/json_data_extractor/schema_element.rb', line 6 def modifiers @modifiers end |
#nested ⇒ Object (readonly)
Returns the value of attribute nested.
6 7 8 |
# File 'lib/json_data_extractor/schema_element.rb', line 6 def nested @nested end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/json_data_extractor/schema_element.rb', line 6 def path @path end |
Instance Method Details
#fetch_default_value ⇒ Object
19 20 21 |
# File 'lib/json_data_extractor/schema_element.rb', line 19 def fetch_default_value @default_value.respond_to?(:call) ? @default_value.call : @default_value end |