Class: Binda::Shopify::Product
- Inherits:
-
Object
- Object
- Binda::Shopify::Product
- Defined in:
- lib/binda/shopify/product.rb
Instance Attribute Summary collapse
-
#product ⇒ Object
Returns the value of attribute product.
-
#shop ⇒ Object
Returns the value of attribute shop.
Instance Method Summary collapse
- #edit_url ⇒ Object
- #id ⇒ Object
-
#initialize(product, shop) ⇒ Product
constructor
A new instance of Product.
- #inventory_item_id ⇒ Object
- #method_missing(name, params = nil, &block) ⇒ Object
Constructor Details
#initialize(product, shop) ⇒ Product
Returns a new instance of Product.
5 6 7 8 |
# File 'lib/binda/shopify/product.rb', line 5 def initialize product, shop @product = product @shop = shop end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, params = nil, &block) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/binda/shopify/product.rb', line 27 def method_missing name, params = nil, &block if product.respond_to? name product.send(name, params) else super end end |
Instance Attribute Details
#product ⇒ Object
Returns the value of attribute product.
4 5 6 |
# File 'lib/binda/shopify/product.rb', line 4 def product @product end |
#shop ⇒ Object
Returns the value of attribute shop.
4 5 6 |
# File 'lib/binda/shopify/product.rb', line 4 def shop @shop end |
Instance Method Details
#edit_url ⇒ Object
23 24 25 |
# File 'lib/binda/shopify/product.rb', line 23 def edit_url "https://#{shop.domain}/admin/products/#{product.id}" end |
#id ⇒ Object
10 11 12 |
# File 'lib/binda/shopify/product.rb', line 10 def id product.id end |
#inventory_item_id ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/binda/shopify/product.rb', line 14 def inventory_item_id variant = variants.first if variant.respond_to? :inventory_item_id variant.inventory_item_id if !variant.nil? else nil end end |