Class: OpenApi::DSL::ExampleObj
- Inherits:
-
Hash
- Object
- Hash
- OpenApi::DSL::ExampleObj
- Includes:
- Helpers
- Defined in:
- lib/oas_objs/example_obj.rb
Overview
Instance Attribute Summary collapse
-
#example_value ⇒ Object
Returns the value of attribute example_value.
-
#examples_hash ⇒ Object
Returns the value of attribute examples_hash.
-
#keys_of_value ⇒ Object
Returns the value of attribute keys_of_value.
Instance Method Summary collapse
-
#initialize(exp, keys_of_value = nil, multiple: false) ⇒ ExampleObj
constructor
A new instance of ExampleObj.
- #process ⇒ Object
Methods included from Helpers
#_combined_schema, #arrow_writing_support, #process_schema_input
Constructor Details
#initialize(exp, keys_of_value = nil, multiple: false) ⇒ ExampleObj
Returns a new instance of ExampleObj.
14 15 16 17 |
# File 'lib/oas_objs/example_obj.rb', line 14 def initialize(exp, keys_of_value = nil, multiple: false) multiple ? self.examples_hash = exp : self.example_value = exp self.keys_of_value = keys_of_value end |
Instance Attribute Details
#example_value ⇒ Object
Returns the value of attribute example_value.
12 13 14 |
# File 'lib/oas_objs/example_obj.rb', line 12 def example_value @example_value end |
#examples_hash ⇒ Object
Returns the value of attribute examples_hash.
12 13 14 |
# File 'lib/oas_objs/example_obj.rb', line 12 def examples_hash @examples_hash end |
#keys_of_value ⇒ Object
Returns the value of attribute keys_of_value.
12 13 14 |
# File 'lib/oas_objs/example_obj.rb', line 12 def keys_of_value @keys_of_value end |
Instance Method Details
#process ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/oas_objs/example_obj.rb', line 19 def process return example_value if example_value return unless examples_hash examples_hash.map do |(name, value)| value = if keys_of_value.present? && value.is_a?(Array) { value: Hash[keys_of_value.zip(value)] } elsif value.is_a?(Symbol) && value['$'] RefObj.new(value.to_s.delete('$'), :example).process else { value: value } end { name => value } end end |