Class: Cadooz::Immutable::Catalog
- Inherits:
-
Object
- Object
- Cadooz::Immutable::Catalog
- Includes:
- Mixins
- Defined in:
- lib/cadooz/models/immutable/catalog.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#products ⇒ Object
readonly
Returns the value of attribute products.
Instance Method Summary collapse
-
#initialize(open_struct) ⇒ Catalog
constructor
A new instance of Catalog.
Methods included from Mixins
#cadooz_class, #default_value_for_nil, #instance_variables_empty?, #serialize
Constructor Details
#initialize(open_struct) ⇒ Catalog
Returns a new instance of Catalog.
6 7 8 9 10 11 12 13 |
# File 'lib/cadooz/models/immutable/catalog.rb', line 6 def initialize(open_struct) @id = open_struct&.id @name = open_struct&.name @description = open_struct&.description @products = Array(open_struct&.products)&.each_with_object([]) { |p, arr| arr << Cadooz::Immutable::CatalogProduct.new(p) } self.freeze end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
4 5 6 |
# File 'lib/cadooz/models/immutable/catalog.rb', line 4 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/cadooz/models/immutable/catalog.rb', line 4 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/cadooz/models/immutable/catalog.rb', line 4 def name @name end |
#products ⇒ Object (readonly)
Returns the value of attribute products.
4 5 6 |
# File 'lib/cadooz/models/immutable/catalog.rb', line 4 def products @products end |