Class: Prestashop::Mapper::StockAvailable
- Defined in:
- lib/prestashop/mapper/models/stock_available.rb
Instance Attribute Summary collapse
-
#depends_on_stock ⇒ Object
Returns the value of attribute depends_on_stock.
-
#id_product ⇒ Object
Returns the value of attribute id_product.
-
#id_product_attribute ⇒ Object
Returns the value of attribute id_product_attribute.
-
#id_shop ⇒ Object
Returns the value of attribute id_shop.
-
#id_shop_group ⇒ Object
Returns the value of attribute id_shop_group.
-
#out_of_stock ⇒ Object
Returns the value of attribute out_of_stock.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
Instance Method Summary collapse
- #id ⇒ Object (also: #find?)
-
#initialize(args = {}) ⇒ StockAvailable
constructor
A new instance of StockAvailable.
- #update(options = {}) ⇒ Object
Methods inherited from Model
#hash_lang, #meta_description, #meta_keywords, #meta_title, model, resource
Methods included from Extension
Constructor Details
#initialize(args = {}) ⇒ StockAvailable
Returns a new instance of StockAvailable.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/prestashop/mapper/models/stock_available.rb', line 10 def initialize args = {} @id = args[:id] @id_product = args[:id_product] @id_product_attribute = args.fetch(:id_product_attribute, 0) @id_shop = args.fetch(:id_shop, 1) @id_shop_group = args.fetch(:id_shop_group, 0) @quantity = args.fetch(:quantity, 0) @depends_on_stock = args.fetch(:depends_on_stock, 0) @out_of_stock = args.fetch(:out_of_stock, 2) end |
Instance Attribute Details
#depends_on_stock ⇒ Object
Returns the value of attribute depends_on_stock.
8 9 10 |
# File 'lib/prestashop/mapper/models/stock_available.rb', line 8 def depends_on_stock @depends_on_stock end |
#id_product ⇒ Object
Returns the value of attribute id_product.
8 9 10 |
# File 'lib/prestashop/mapper/models/stock_available.rb', line 8 def id_product @id_product end |
#id_product_attribute ⇒ Object
Returns the value of attribute id_product_attribute.
8 9 10 |
# File 'lib/prestashop/mapper/models/stock_available.rb', line 8 def id_product_attribute @id_product_attribute end |
#id_shop ⇒ Object
Returns the value of attribute id_shop.
8 9 10 |
# File 'lib/prestashop/mapper/models/stock_available.rb', line 8 def id_shop @id_shop end |
#id_shop_group ⇒ Object
Returns the value of attribute id_shop_group.
8 9 10 |
# File 'lib/prestashop/mapper/models/stock_available.rb', line 8 def id_shop_group @id_shop_group end |
#out_of_stock ⇒ Object
Returns the value of attribute out_of_stock.
8 9 10 |
# File 'lib/prestashop/mapper/models/stock_available.rb', line 8 def out_of_stock @out_of_stock end |
#quantity ⇒ Object
Returns the value of attribute quantity.
8 9 10 |
# File 'lib/prestashop/mapper/models/stock_available.rb', line 8 def quantity @quantity end |
Instance Method Details
#id ⇒ Object Also known as: find?
21 22 23 24 25 26 27 |
# File 'lib/prestashop/mapper/models/stock_available.rb', line 21 def id @id ||= if id_product_attribute == 0 self.class.find_by 'filter[id_product]' => id_product else self.class.find_by 'filter[id_product]' => id_product, 'filter[id_product_attribute]' => id_product_attribute end end |
#update(options = {}) ⇒ Object
30 31 32 |
# File 'lib/prestashop/mapper/models/stock_available.rb', line 30 def update = {} self.class.update(id, ) if find? end |