Class: InventoryWrapper
- Inherits:
-
Object
- Object
- InventoryWrapper
- Defined in:
- app/my_lib/inventory_wrapper.rb
Overview
InventoryWrapper is a class that wraps around different inventory classes based on the inventory source of a restaurant.
Instance Attribute Summary collapse
-
#is_dine_in ⇒ Object
readonly
Returns the value of attribute is_dine_in.
-
#restaurant ⇒ Object
readonly
The restaurant object which contains the inventory source.
-
#service_type ⇒ Object
readonly
Returns the value of attribute service_type.
Instance Method Summary collapse
-
#initialize(restaurant_id:, is_dine_in: nil, service_type: nil) ⇒ InventoryWrapper
constructor
Initializes a new InventoryWrapper object.
-
#inv_model ⇒ Class
Determines the inventory model class based on the restaurant's inventory source.
Constructor Details
#initialize(restaurant_id:, is_dine_in: nil, service_type: nil) ⇒ InventoryWrapper
Initializes a new InventoryWrapper object.
13 14 15 16 |
# File 'app/my_lib/inventory_wrapper.rb', line 13 def initialize(restaurant_id:, is_dine_in: nil, service_type: nil) @restaurant = Restaurant.find_by(id: restaurant_id) @is_dine_in = determine_dine_in_status(is_dine_in, service_type) end |
Instance Attribute Details
#is_dine_in ⇒ Object (readonly)
Returns the value of attribute is_dine_in.
6 7 8 |
# File 'app/my_lib/inventory_wrapper.rb', line 6 def is_dine_in @is_dine_in end |
#restaurant ⇒ Object (readonly)
The restaurant object which contains the inventory source
5 6 7 |
# File 'app/my_lib/inventory_wrapper.rb', line 5 def restaurant @restaurant end |
#service_type ⇒ Object (readonly)
Returns the value of attribute service_type.
6 7 8 |
# File 'app/my_lib/inventory_wrapper.rb', line 6 def service_type @service_type end |
Instance Method Details
#inv_model ⇒ Class
Determines the inventory model class based on the restaurant's inventory source.
21 22 23 24 25 |
# File 'app/my_lib/inventory_wrapper.rb', line 21 def inv_model return nil unless restaurant determine_inventory_model end |