Class: Workarea::Inventory::Policies::Base

Inherits:
Object
  • Object
show all
Defined in:
app/models/workarea/inventory/policies/base.rb

Direct Known Subclasses

AllowBackorder, Ignore, Standard

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#skuObject (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_sellInteger

Returns the quantity of available units of the SKU for sale

Returns:

  • (Integer)

    count

Raises:

  • (NotImplementedError)


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.

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


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.

Returns:

  • (Hash)

Raises:

  • (NotImplementedError)


38
39
40
# File 'app/models/workarea/inventory/policies/base.rb', line 38

def purchase(quantity)
  raise(NotImplementedError)
end