Class: InventoryWrapper

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(restaurant_id:, is_dine_in: nil, service_type: nil) ⇒ InventoryWrapper

Initializes a new InventoryWrapper object.

Parameters:

  • restaurant_id (Integer)

    The ID of the restaurant object which contains the inventory source.

  • is_dine_in (Boolean, nil) (defaults to: nil)

    Indicates if the service is dine-in.

  • service_type (Object, nil) (defaults to: nil)

    The service type object which can determine if it's dine-in.



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_inObject (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

#restaurantObject (readonly)

The restaurant object which contains the inventory source

Returns:

  • (Object)

    the current value of restaurant



5
6
7
# File 'app/my_lib/inventory_wrapper.rb', line 5

def restaurant
  @restaurant
end

#service_typeObject (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_modelClass

Determines the inventory model class based on the restaurant's inventory source.

Returns:

  • (Class)

    The inventory model class.



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