Class: Cadooz::Immutable::CatalogProduct

Inherits:
Object
  • Object
show all
Includes:
Mixins
Defined in:
lib/cadooz/models/immutable/catalog_product.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) ⇒ CatalogProduct

Returns a new instance of CatalogProduct.



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/cadooz/models/immutable/catalog_product.rb', line 6

def initialize(open_struct)
  @attributes = Array(open_struct&.attributes)&.each_with_object([]) { |a, arr| arr << Cadooz::Immutable::Attributes.new(a) }
  @categories = Array(open_struct&.categories)&.each_with_object([]) { |c, arr| arr << Cadooz::Immutable::ProductCategory.new(c) }
  @mobile_shippable = open_struct&.mobile_shippable
  @name = open_struct&.name
  @number = open_struct&.number
  @offline_shippable = open_struct&.offline_shippable
  @online_shippable = open_struct&.online_shippable
  @type = open_struct&.type
  @variations = Array(open_struct&.variations)&.each_with_object([]) { |v, arr| arr << Cadooz::Immutable::CatalogProductVariation.new(v) }

  self.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

#categoriesObject (readonly)

Returns the value of attribute categories.



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

def categories
  @categories
end

#mobile_shippableObject (readonly)

Returns the value of attribute mobile_shippable.



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

def mobile_shippable
  @mobile_shippable
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number.



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

def number
  @number
end

#offline_shippableObject (readonly)

Returns the value of attribute offline_shippable.



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

def offline_shippable
  @offline_shippable
end

#online_shippableObject (readonly)

Returns the value of attribute online_shippable.



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

def online_shippable
  @online_shippable
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

#variationsObject (readonly)

Returns the value of attribute variations.



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

def variations
  @variations
end