Class: SpreeCmCommissioner::RedisStock::VariantCachedInventoryItemsBuilder
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::RedisStock::VariantCachedInventoryItemsBuilder
- Defined in:
- app/models/spree_cm_commissioner/redis_stock/variant_cached_inventory_items_builder.rb
Instance Attribute Summary collapse
-
#dates ⇒ Object
readonly
Returns the value of attribute dates.
-
#variant_id ⇒ Object
readonly
Returns the value of attribute variant_id.
Instance Method Summary collapse
-
#call ⇒ Object
output: [ CachedInventoryItem(…), CachedInventoryItem(…) ].
-
#initialize(variant_id:, dates: []) ⇒ VariantCachedInventoryItemsBuilder
constructor
A new instance of VariantCachedInventoryItemsBuilder.
- #inventory_items ⇒ Object
Constructor Details
#initialize(variant_id:, dates: []) ⇒ VariantCachedInventoryItemsBuilder
Returns a new instance of VariantCachedInventoryItemsBuilder.
6 7 8 9 |
# File 'app/models/spree_cm_commissioner/redis_stock/variant_cached_inventory_items_builder.rb', line 6 def initialize(variant_id:, dates: []) @variant_id = variant_id @dates = dates end |
Instance Attribute Details
#dates ⇒ Object (readonly)
Returns the value of attribute dates.
4 5 6 |
# File 'app/models/spree_cm_commissioner/redis_stock/variant_cached_inventory_items_builder.rb', line 4 def dates @dates end |
#variant_id ⇒ Object (readonly)
Returns the value of attribute variant_id.
4 5 6 |
# File 'app/models/spree_cm_commissioner/redis_stock/variant_cached_inventory_items_builder.rb', line 4 def variant_id @variant_id end |
Instance Method Details
#call ⇒ Object
output: [ CachedInventoryItem(…), CachedInventoryItem(…) ]
12 13 14 |
# File 'app/models/spree_cm_commissioner/redis_stock/variant_cached_inventory_items_builder.rb', line 12 def call ::SpreeCmCommissioner::RedisStock::CachedInventoryItemsBuilder.new(inventory_items).call end |
#inventory_items ⇒ Object
16 17 18 19 20 21 22 |
# File 'app/models/spree_cm_commissioner/redis_stock/variant_cached_inventory_items_builder.rb', line 16 def inventory_items variant = Spree::Variant.find(variant_id) inventory_items = variant.inventory_items inventory_items = inventory_items.where(inventory_date: dates) if variant.permanent_stock? inventory_items end |