Class: Brujula::ObjectParser
- Inherits:
-
Object
- Object
- Brujula::ObjectParser
- Defined in:
- lib/brujula/object_parser.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(definition:, data:, parent: :root) ⇒ ObjectParser
constructor
A new instance of ObjectParser.
Constructor Details
#initialize(definition:, data:, parent: :root) ⇒ ObjectParser
Returns a new instance of ObjectParser.
11 12 13 14 15 |
# File 'lib/brujula/object_parser.rb', line 11 def initialize(definition:, data:, parent: :root) @definition = definition @parent = parent @data = data end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
9 10 11 |
# File 'lib/brujula/object_parser.rb', line 9 def args @args end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
9 10 11 |
# File 'lib/brujula/object_parser.rb', line 9 def data @data end |
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
9 10 11 |
# File 'lib/brujula/object_parser.rb', line 9 def definition @definition end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
9 10 11 |
# File 'lib/brujula/object_parser.rb', line 9 def parent @parent end |
Class Method Details
.call(definition:, data:, parent: :root) ⇒ Object
4 5 6 |
# File 'lib/brujula/object_parser.rb', line 4 def call(definition:, data:, parent: :root) new(definition: definition, data: data, parent: parent).call end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/brujula/object_parser.rb', line 17 def call return data if not_processable_external_data? scheme_keys.each do |key| object_instance = object_builder(key).call definition.instance_variable_set( "@#{ key.accessor_name }", object_instance ) end end |