Class: Sublayer::Components::OutputAdapters::ListOfNamedStrings
- Inherits:
-
Object
- Object
- Sublayer::Components::OutputAdapters::ListOfNamedStrings
- Defined in:
- lib/sublayer/components/output_adapters/list_of_named_strings.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#item_name ⇒ Object
readonly
Returns the value of attribute item_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(options) ⇒ ListOfNamedStrings
constructor
A new instance of ListOfNamedStrings.
- #materialize_result(raw_results) ⇒ Object
- #properties ⇒ Object
Constructor Details
#initialize(options) ⇒ ListOfNamedStrings
Returns a new instance of ListOfNamedStrings.
7 8 9 10 11 12 |
# File 'lib/sublayer/components/output_adapters/list_of_named_strings.rb', line 7 def initialize() @name = [:name] @item_name = [:item_name] @description = [:description] @attributes = [:attributes] end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/sublayer/components/output_adapters/list_of_named_strings.rb', line 5 def attributes @attributes end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/sublayer/components/output_adapters/list_of_named_strings.rb', line 5 def description @description end |
#item_name ⇒ Object (readonly)
Returns the value of attribute item_name.
5 6 7 |
# File 'lib/sublayer/components/output_adapters/list_of_named_strings.rb', line 5 def item_name @item_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/sublayer/components/output_adapters/list_of_named_strings.rb', line 5 def name @name end |
Instance Method Details
#materialize_result(raw_results) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/sublayer/components/output_adapters/list_of_named_strings.rb', line 38 def materialize_result(raw_results) raw_results.map do |raw_result| OpenStruct.new( @attributes.map { |attribute| [attribute[:name], raw_result[attribute[:name]]] }.to_h ) end end |
#properties ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/sublayer/components/output_adapters/list_of_named_strings.rb', line 14 def properties [ OpenStruct.new( name: @name, type: "array", description: @description, required: true, items: OpenStruct.new( type: "object", description: "a single #{@item_name}", name: @item_name, properties: @attributes.map do |attribute| OpenStruct.new( type: "string", name: attribute[:name], description: attribute[:description], required: true ) end ) ) ] end |