Class: Gemgento::Magento::ShipmentItemAdapter
- Inherits:
-
Object
- Object
- Gemgento::Magento::ShipmentItemAdapter
- Defined in:
- app/adapters/gemgento/magento/shipment_item_adapter.rb
Instance Attribute Summary collapse
- #shipment ⇒ Gemgento::Shipment
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #import ⇒ Gemgento::ShipmentItemAdapter
-
#initialize(source, shipment = nil) ⇒ ShipmentItemAdapter
constructor
A new instance of ShipmentItemAdapter.
- #order ⇒ Gemgento::Order
Constructor Details
#initialize(source, shipment = nil) ⇒ ShipmentItemAdapter
Returns a new instance of ShipmentItemAdapter.
8 9 10 11 |
# File 'app/adapters/gemgento/magento/shipment_item_adapter.rb', line 8 def initialize(source, shipment = nil) @source = source @shipment = shipment end |
Instance Attribute Details
#shipment ⇒ Gemgento::Shipment
29 30 31 |
# File 'app/adapters/gemgento/magento/shipment_item_adapter.rb', line 29 def shipment @shipment end |
#source ⇒ Object
Returns the value of attribute source.
4 5 6 |
# File 'app/adapters/gemgento/magento/shipment_item_adapter.rb', line 4 def source @source end |
Instance Method Details
#import ⇒ Gemgento::ShipmentItemAdapter
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/adapters/gemgento/magento/shipment_item_adapter.rb', line 14 def import shipment_item = Gemgento::ShipmentItem.find_or_initialize_by(magento_id: self.source[:item_id]) shipment_item.shipment = self.shipment shipment_item.line_item = self.order.line_items.find_by!(magento_id: self.source[:order_item_id]) shipment_item.sku = self.source[:sku] shipment_item.name = self.source[:name] shipment_item.weight = self.source[:weight] shipment_item.price = self.source[:price] shipment_item.quantity = self.source[:qty] shipment_item.save! return shipment_item end |
#order ⇒ Gemgento::Order
34 35 36 |
# File 'app/adapters/gemgento/magento/shipment_item_adapter.rb', line 34 def order @order ||= self.shipment.order end |