Class: Pobo::DTO::Parameter
- Inherits:
-
Object
- Object
- Pobo::DTO::Parameter
- Defined in:
- lib/pobo/dto/parameter.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id:, name:, values: []) ⇒ Parameter
constructor
A new instance of Parameter.
- #to_hash ⇒ Object (also: #to_h)
Constructor Details
#initialize(id:, name:, values: []) ⇒ Parameter
Returns a new instance of Parameter.
33 34 35 36 37 |
# File 'lib/pobo/dto/parameter.rb', line 33 def initialize(id:, name:, values: []) @id = id @name = name @values = values end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
31 32 33 |
# File 'lib/pobo/dto/parameter.rb', line 31 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
31 32 33 |
# File 'lib/pobo/dto/parameter.rb', line 31 def name @name end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
31 32 33 |
# File 'lib/pobo/dto/parameter.rb', line 31 def values @values end |
Class Method Details
.from_hash(hash) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/pobo/dto/parameter.rb', line 39 def self.from_hash(hash) values = (hash["values"] || hash[:values] || []).map do |v| ParameterValue.from_hash(v) end new( id: hash["id"] || hash[:id], name: hash["name"] || hash[:name], values: values ) end |
Instance Method Details
#to_hash ⇒ Object Also known as: to_h
51 52 53 54 55 56 57 |
# File 'lib/pobo/dto/parameter.rb', line 51 def to_hash { "id" => @id, "name" => @name, "values" => @values.map(&:to_hash) } end |