Class: Sublayer::Components::OutputAdapters::NamedStrings
- Inherits:
-
Object
- Object
- Sublayer::Components::OutputAdapters::NamedStrings
- Defined in:
- lib/sublayer/components/output_adapters/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.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(options) ⇒ NamedStrings
constructor
A new instance of NamedStrings.
- #materialize_result(raw_result) ⇒ Object
- #properties ⇒ Object
Constructor Details
#initialize(options) ⇒ NamedStrings
Returns a new instance of NamedStrings.
7 8 9 10 11 |
# File 'lib/sublayer/components/output_adapters/named_strings.rb', line 7 def initialize() @name = [: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/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/named_strings.rb', line 5 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/sublayer/components/output_adapters/named_strings.rb', line 5 def name @name end |
Instance Method Details
#materialize_result(raw_result) ⇒ Object
27 28 29 |
# File 'lib/sublayer/components/output_adapters/named_strings.rb', line 27 def materialize_result(raw_result) OpenStruct.new( @attributes.map { |attribute| [attribute[:name], raw_result[attribute[:name]]] }.to_h) end |
#properties ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sublayer/components/output_adapters/named_strings.rb', line 13 def properties [ OpenStruct.new( name: @name, type: "object", description: @description, required: true, properties: @attributes.map { |attribute| OpenStruct.new(type: "string", description: attribute[:description], required: true, name: attribute[:name]) } ) ] end |