Class: Cadooz::Immutable::Catalog

Inherits:
Object
  • Object
show all
Includes:
Mixins
Defined in:
lib/cadooz/models/immutable/catalog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#descriptionObject (readonly)

Returns the value of attribute description.



4
5
6
# File 'lib/cadooz/models/immutable/catalog.rb', line 4

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/cadooz/models/immutable/catalog.rb', line 4

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/cadooz/models/immutable/catalog.rb', line 4

def name
  @name
end

#productsObject (readonly)

Returns the value of attribute products.



4
5
6
# File 'lib/cadooz/models/immutable/catalog.rb', line 4

def products
  @products
end