Class: Workarea::Inventory::Policies::Base
- Inherits:
-
Object
- Object
- Workarea::Inventory::Policies::Base
- Defined in:
- app/models/workarea/inventory/policies/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#sku ⇒ Object
readonly
Returns the value of attribute sku.
Instance Method Summary collapse
-
#available_to_sell ⇒ Integer
Returns the quantity of available units of the SKU for sale.
-
#displayable? ⇒ Boolean
Whether this SKU should contribute to being displayed with resepect to inventory.
-
#initialize(sku) ⇒ Base
constructor
A new instance of Base.
-
#purchase(quantity) ⇒ Hash
Decrement the inventory required to represent a purchase for this policy.
Constructor Details
#initialize(sku) ⇒ Base
Returns a new instance of Base.
7 8 9 |
# File 'app/models/workarea/inventory/policies/base.rb', line 7 def initialize(sku) @sku = sku end |
Instance Attribute Details
#sku ⇒ Object (readonly)
Returns the value of attribute sku.
5 6 7 |
# File 'app/models/workarea/inventory/policies/base.rb', line 5 def sku @sku end |
Instance Method Details
#available_to_sell ⇒ Integer
Returns the quantity of available units of the SKU for sale
24 25 26 |
# File 'app/models/workarea/inventory/policies/base.rb', line 24 def available_to_sell raise(NotImplementedError) end |
#displayable? ⇒ Boolean
Whether this SKU should contribute to being displayed with resepect to inventory.
16 17 18 |
# File 'app/models/workarea/inventory/policies/base.rb', line 16 def displayable? raise(NotImplementedError) end |
#purchase(quantity) ⇒ Hash
Decrement the inventory required to represent a purchase for this policy. Commonly, this would do some logic to decide how many units to capture and call Sku#capture.
Returns a hash with results to record how many were captured, for later rolling back if necessary. Hash has keys for available and backordered counts.
38 39 40 |
# File 'app/models/workarea/inventory/policies/base.rb', line 38 def purchase(quantity) raise(NotImplementedError) end |