Class: Cornerstore::Shipment
- Inherits:
-
Model::Base
- Object
- Model::Base
- Cornerstore::Shipment
- Defined in:
- lib/cornerstore/api/shipment.rb
Defined Under Namespace
Classes: Resource
Instance Attribute Summary collapse
-
#carrier ⇒ Object
Returns the value of attribute carrier.
-
#created_at ⇒ Object
(also: #shipped_at)
Returns the value of attribute created_at.
-
#line_item_ids ⇒ Object
Returns the value of attribute line_item_ids.
-
#tracking_number ⇒ Object
Returns the value of attribute tracking_number.
Attributes inherited from Model::Base
#_id, #_slugs, #parent, #updated_at
Instance Method Summary collapse
-
#initialize(attributes = {}, parent = nil) ⇒ Shipment
constructor
A new instance of Shipment.
- #line_items ⇒ Object (also: #shipped_items)
Methods inherited from Model::Base
#==, #attributes, #attributes=, #inspect, #method_missing, method_missing, #to_param, #url
Constructor Details
#initialize(attributes = {}, parent = nil) ⇒ Shipment
Returns a new instance of Shipment.
9 10 11 12 13 |
# File 'lib/cornerstore/api/shipment.rb', line 9 def initialize(attributes = {}, parent=nil) self.carrier = Cornerstore::Carrier.new(attributes.delete('carrier')) self.line_item_ids = attributes.delete('shipped_items') super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Cornerstore::Model::Base
Instance Attribute Details
#carrier ⇒ Object
Returns the value of attribute carrier.
2 3 4 |
# File 'lib/cornerstore/api/shipment.rb', line 2 def carrier @carrier end |
#created_at ⇒ Object Also known as: shipped_at
Returns the value of attribute created_at.
2 3 4 |
# File 'lib/cornerstore/api/shipment.rb', line 2 def created_at @created_at end |
#line_item_ids ⇒ Object
Returns the value of attribute line_item_ids.
2 3 4 |
# File 'lib/cornerstore/api/shipment.rb', line 2 def line_item_ids @line_item_ids end |
#tracking_number ⇒ Object
Returns the value of attribute tracking_number.
2 3 4 |
# File 'lib/cornerstore/api/shipment.rb', line 2 def tracking_number @tracking_number end |
Instance Method Details
#line_items ⇒ Object Also known as: shipped_items
15 16 17 18 |
# File 'lib/cornerstore/api/shipment.rb', line 15 def line_items return [] unless self.parent self.parent.line_items.select { |li| self.line_item_ids.include?(li.id) } end |