Class: Raas::CatalogModel
- Defined in:
- lib/raas/models/catalog_model.rb
Overview
Represents a Catalog
Instance Attribute Summary collapse
-
#brands ⇒ List of BrandModel
The brands in your catalog.
-
#catalog_name ⇒ String
The name of your catalog.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
Instance Method Summary collapse
-
#initialize(catalog_name = nil, brands = nil) ⇒ CatalogModel
constructor
A new instance of CatalogModel.
Methods inherited from BaseModel
Constructor Details
#initialize(catalog_name = nil, brands = nil) ⇒ CatalogModel
Returns a new instance of CatalogModel.
23 24 25 26 27 |
# File 'lib/raas/models/catalog_model.rb', line 23 def initialize(catalog_name = nil, brands = nil) @catalog_name = catalog_name @brands = brands end |
Instance Attribute Details
#brands ⇒ List of BrandModel
The brands in your catalog
13 14 15 |
# File 'lib/raas/models/catalog_model.rb', line 13 def brands @brands end |
#catalog_name ⇒ String
The name of your catalog
9 10 11 |
# File 'lib/raas/models/catalog_model.rb', line 9 def catalog_name @catalog_name end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/raas/models/catalog_model.rb', line 30 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. catalog_name = hash['catalogName'] # Parameter is an array, so we need to iterate through it brands = nil unless hash['brands'].nil? brands = [] hash['brands'].each do |structure| brands << (BrandModel.from_hash(structure) if structure) end end # Create object from extracted values. CatalogModel.new(catalog_name, brands) end |
.names ⇒ Object
A mapping from model property names to API property names.
16 17 18 19 20 21 |
# File 'lib/raas/models/catalog_model.rb', line 16 def self.names @_hash = {} if @_hash.nil? @_hash['catalog_name'] = 'catalogName' @_hash['brands'] = 'brands' @_hash end |