Class: Spree::Shipstation::Export::ItemPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/spree/shipstation/export/item_presenter.rb

Overview

Shapes a shipment line item (a line item plus its inventory units) into the values ShipStation's export XML expects for an .

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line_item, units) ⇒ ItemPresenter

Returns a new instance of ItemPresenter.



11
12
13
14
# File 'app/presenters/spree/shipstation/export/item_presenter.rb', line 11

def initialize(line_item, units)
  @line_item = line_item
  @units = units
end

Instance Attribute Details

#line_itemObject (readonly)

Returns the value of attribute line_item.



9
10
11
# File 'app/presenters/spree/shipstation/export/item_presenter.rb', line 9

def line_item
  @line_item
end

#unitsObject (readonly)

Returns the value of attribute units.



9
10
11
# File 'app/presenters/spree/shipstation/export/item_presenter.rb', line 9

def units
  @units
end

Instance Method Details

#imageObject

The Spree::Image to advertise, or nil. URL generation stays in the view because it depends on Rails route/URL helpers.



30
31
32
# File 'app/presenters/spree/shipstation/export/item_presenter.rb', line 30

def image
  variant.images.first || variant.product.master.images.first
end

#nameObject



24
25
26
# File 'app/presenters/spree/shipstation/export/item_presenter.rb', line 24

def name
  [variant.product.name, variant.options_text].reject(&:blank?).join(" ")
end

#option_valuesObject



46
47
48
# File 'app/presenters/spree/shipstation/export/item_presenter.rb', line 46

def option_values
  variant.option_values
end

#quantityObject



38
39
40
# File 'app/presenters/spree/shipstation/export/item_presenter.rb', line 38

def quantity
  units.size
end

#skuObject



20
21
22
# File 'app/presenters/spree/shipstation/export/item_presenter.rb', line 20

def sku
  variant.sku
end

#unit_priceObject



42
43
44
# File 'app/presenters/spree/shipstation/export/item_presenter.rb', line 42

def unit_price
  line_item.price
end

#variantObject



16
17
18
# File 'app/presenters/spree/shipstation/export/item_presenter.rb', line 16

def variant
  @variant ||= line_item.variant
end

#weightObject



34
35
36
# File 'app/presenters/spree/shipstation/export/item_presenter.rb', line 34

def weight
  Weight.from_variant(variant)
end