Class: Binda::Shopify::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/binda/shopify/item.rb

Direct Known Subclasses

Collection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item, shop) ⇒ Item

Returns a new instance of Item.



6
7
8
9
# File 'lib/binda/shopify/item.rb', line 6

def initialize item, shop
  @item = item
  @shop = shop
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, params = nil, &block) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/binda/shopify/item.rb', line 19

def method_missing name, params = nil, &block
  if item.respond_to? name
    item.send(name, params)
  else
    super
  end
end

Instance Attribute Details

#itemObject

Returns the value of attribute item.



4
5
6
# File 'lib/binda/shopify/item.rb', line 4

def item
  @item
end

#shopObject

Returns the value of attribute shop.



4
5
6
# File 'lib/binda/shopify/item.rb', line 4

def shop
  @shop
end

Instance Method Details

#edit_urlObject



15
16
17
# File 'lib/binda/shopify/item.rb', line 15

def edit_url
  "https://#{shop.domain}/admin/#{item.model_name.element.pluralize}/#{item.id}"
end

#idObject



11
12
13
# File 'lib/binda/shopify/item.rb', line 11

def id
  item.id
end