Class: InventoryV2Worker::Service
- Inherits:
-
Object
- Object
- InventoryV2Worker::Service
- Includes:
- ElasticAPM::SpanHelpers
- Defined in:
- app/workers/inventory_v2_worker.rb
Overview
Service class to handle the inventory generation logic. It processes the inventories for a specific restaurant and service type (dine_in or take_away). It can also clear existing inventories if Operation team click “remake” button
Instance Attribute Summary collapse
-
#date_to_generates ⇒ Object
readonly
Returns the value of attribute date_to_generates.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#remade ⇒ Object
readonly
Returns the value of attribute remade.
-
#restaurant ⇒ Object
readonly
Returns the value of attribute restaurant.
-
#service_type ⇒ Object
readonly
Returns the value of attribute service_type.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(restaurant_id, service_type, remade = false) ⇒ Service
constructor
A new instance of Service.
Constructor Details
#initialize(restaurant_id, service_type, remade = false) ⇒ Service
Returns a new instance of Service.
26 27 28 29 30 31 32 33 34 |
# File 'app/workers/inventory_v2_worker.rb', line 26 def initialize(restaurant_id, service_type, remade = false) @service_type = service_type.to_s @restaurant = Restaurant.find(restaurant_id) @remade = remade @model = select_model @date_to_generates = Set.new @inventories = [] @inventories_of_updated_inventories = [] end |
Instance Attribute Details
#date_to_generates ⇒ Object (readonly)
Returns the value of attribute date_to_generates.
21 22 23 |
# File 'app/workers/inventory_v2_worker.rb', line 21 def date_to_generates @date_to_generates end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
21 22 23 |
# File 'app/workers/inventory_v2_worker.rb', line 21 def model @model end |
#remade ⇒ Object (readonly)
Returns the value of attribute remade.
21 22 23 |
# File 'app/workers/inventory_v2_worker.rb', line 21 def remade @remade end |
#restaurant ⇒ Object (readonly)
Returns the value of attribute restaurant.
21 22 23 |
# File 'app/workers/inventory_v2_worker.rb', line 21 def restaurant @restaurant end |
#service_type ⇒ Object (readonly)
Returns the value of attribute service_type.
21 22 23 |
# File 'app/workers/inventory_v2_worker.rb', line 21 def service_type @service_type end |
Instance Method Details
#call ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'app/workers/inventory_v2_worker.rb', line 36 def call # we don't sell take away products anymore return if @model == InventoryTakeAway clear_existing_inventories if remade process_inventories end |