Class: Accountability::Inventory
- Inherits:
-
Object
- Object
- Accountability::Inventory
- Extended by:
- Forwardable
- Defined in:
- app/models/accountability/inventory.rb
Defined Under Namespace
Classes: InventoryItem
Instance Attribute Summary collapse
-
#product ⇒ Object
Returns the value of attribute product.
Instance Method Summary collapse
- #available ⇒ Object
- #collection ⇒ Object
-
#initialize(product, available_only: false) ⇒ Inventory
constructor
A new instance of Inventory.
Constructor Details
#initialize(product, available_only: false) ⇒ Inventory
Returns a new instance of Inventory.
22 23 24 25 |
# File 'app/models/accountability/inventory.rb', line 22 def initialize(product, available_only: false) @product = product @scope_availability = available_only end |
Instance Attribute Details
#product ⇒ Object
Returns the value of attribute product.
17 18 19 |
# File 'app/models/accountability/inventory.rb', line 17 def product @product end |
Instance Method Details
#available ⇒ Object
34 35 36 37 38 |
# File 'app/models/accountability/inventory.rb', line 34 def available @scope_availability = true self end |
#collection ⇒ Object
27 28 29 30 31 32 |
# File 'app/models/accountability/inventory.rb', line 27 def collection records = source_class.where(**source_scope) records = records.public_send(offerable_template.whitelist) if scope_availability? records.map { |record| InventoryItem.new(record: record, product: product) } end |