Class: Brujula::DataTransformers::PropertyDeclaration
- Inherits:
-
Object
- Object
- Brujula::DataTransformers::PropertyDeclaration
- Defined in:
- lib/brujula/data_transformers/property_declaration.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(parent, data) ⇒ PropertyDeclaration
constructor
A new instance of PropertyDeclaration.
Constructor Details
#initialize(parent, data) ⇒ PropertyDeclaration
Returns a new instance of PropertyDeclaration.
12 13 14 15 |
# File 'lib/brujula/data_transformers/property_declaration.rb', line 12 def initialize(parent, data) @parent = parent @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
10 11 12 |
# File 'lib/brujula/data_transformers/property_declaration.rb', line 10 def data @data end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
10 11 12 |
# File 'lib/brujula/data_transformers/property_declaration.rb', line 10 def parent @parent end |
Class Method Details
.call(*args) ⇒ Object
5 6 7 |
# File 'lib/brujula/data_transformers/property_declaration.rb', line 5 def call(*args) new(*args).call end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/brujula/data_transformers/property_declaration.rb', line 17 def call data.each_with_object({}) do |(key, property), object| if property.is_a?(String) # data as type object.merge!(key.gsub(/\?$/, "") => { "type" => property, "required" => !key.to_s.end_with?("?") }) else object.merge!(key => property) end end end |