Class: Comable::Inventory::Package
- Inherits:
-
Object
- Object
- Comable::Inventory::Package
- Defined in:
- app/models/comable/inventory/package.rb
Instance Attribute Summary collapse
-
#stock_location ⇒ Object
Returns the value of attribute stock_location.
-
#units ⇒ Object
Returns the value of attribute units.
Instance Method Summary collapse
- #add(unit) ⇒ Object
- #find(unit) ⇒ Object
-
#initialize(stock_location) ⇒ Package
constructor
A new instance of Package.
- #initialize_copy(package) ⇒ Object
- #remove(unit) ⇒ Object
- #to_shipment ⇒ Object
Constructor Details
#initialize(stock_location) ⇒ Package
Returns a new instance of Package.
9 10 11 12 |
# File 'app/models/comable/inventory/package.rb', line 9 def initialize(stock_location) @stock_location = stock_location @units = [] end |
Instance Attribute Details
#stock_location ⇒ Object
Returns the value of attribute stock_location.
4 5 6 |
# File 'app/models/comable/inventory/package.rb', line 4 def stock_location @stock_location end |
#units ⇒ Object
Returns the value of attribute units.
5 6 7 |
# File 'app/models/comable/inventory/package.rb', line 5 def units @units end |
Instance Method Details
#add(unit) ⇒ Object
29 30 31 32 |
# File 'app/models/comable/inventory/package.rb', line 29 def add(unit) unit = [unit] unless unit.is_a? Array units.concat(unit) end |
#find(unit) ⇒ Object
25 26 27 |
# File 'app/models/comable/inventory/package.rb', line 25 def find(unit) units.detect { |u| u == unit } end |
#initialize_copy(package) ⇒ Object
14 15 16 17 |
# File 'app/models/comable/inventory/package.rb', line 14 def initialize_copy(package) super self.units = package.units.clone end |
#remove(unit) ⇒ Object
34 35 36 |
# File 'app/models/comable/inventory/package.rb', line 34 def remove(unit) units.delete(unit) end |