Class: Spree::Shipstation::Export::ItemPresenter
- Inherits:
-
Object
- Object
- Spree::Shipstation::Export::ItemPresenter
- 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
-
#line_item ⇒ Object
readonly
Returns the value of attribute line_item.
-
#units ⇒ Object
readonly
Returns the value of attribute units.
Instance Method Summary collapse
-
#image ⇒ Object
The Spree::Image to advertise, or nil.
-
#initialize(line_item, units) ⇒ ItemPresenter
constructor
A new instance of ItemPresenter.
- #name ⇒ Object
- #option_values ⇒ Object
- #quantity ⇒ Object
- #sku ⇒ Object
- #unit_price ⇒ Object
- #variant ⇒ Object
- #weight ⇒ Object
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_item ⇒ Object (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 |
#units ⇒ Object (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
#image ⇒ Object
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 |
#name ⇒ Object
24 25 26 |
# File 'app/presenters/spree/shipstation/export/item_presenter.rb', line 24 def name [variant.product.name, variant.].reject(&:blank?).join(" ") end |
#option_values ⇒ Object
46 47 48 |
# File 'app/presenters/spree/shipstation/export/item_presenter.rb', line 46 def option_values variant.option_values end |
#quantity ⇒ Object
38 39 40 |
# File 'app/presenters/spree/shipstation/export/item_presenter.rb', line 38 def quantity units.size end |
#sku ⇒ Object
20 21 22 |
# File 'app/presenters/spree/shipstation/export/item_presenter.rb', line 20 def sku variant.sku end |
#unit_price ⇒ Object
42 43 44 |
# File 'app/presenters/spree/shipstation/export/item_presenter.rb', line 42 def unit_price line_item.price end |
#variant ⇒ Object
16 17 18 |
# File 'app/presenters/spree/shipstation/export/item_presenter.rb', line 16 def variant @variant ||= line_item.variant end |
#weight ⇒ Object
34 35 36 |
# File 'app/presenters/spree/shipstation/export/item_presenter.rb', line 34 def weight Weight.from_variant(variant) end |