Class: Inventory::InvCheckerBaseService
- Inherits:
-
Object
- Object
- Inventory::InvCheckerBaseService
- Defined in:
- app/services/inventory/inv_checker_base_service.rb
Overview
Base class for inventory checker services.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#restaurant_id ⇒ Object
readonly
Returns the value of attribute restaurant_id.
-
#time_zone ⇒ Object
readonly
Returns the value of attribute time_zone.
Class Method Summary collapse
- .update_cache_value(restaurant_id:, restaurant_package_id: nil, restaurant_package_ids: [], reservation_level: false, restaurant_level: false, restaurant_package_level: false, dates: [], datetimes: [], reset_mode: false) ⇒ Object
-
.warm_up_cache(restaurant_id, dates) ⇒ Object
subclass has to implement this class method to warm up the cache.
Instance Method Summary collapse
-
#add_on_bookable?(date:, start_time:, r_add_on_id:) ⇒ Boolean
Determines if an add-on is bookable on a specific date and time.
-
#available_add_ons(date:, start_time:, r_add_on_ids:) ⇒ Array
Find available add-ons for a given date, start time, number of adults, and number of kids.
-
#available_packages(date:, start_time:, adult:, kids:) ⇒ Array
Calculates the available packages for a given date, start time, number of adults, and number of kids.
-
#bookable?(date:, start_time:, adult:, kids:) ⇒ Boolean
Determines if a booking is possible for the specified parameters.
-
#bookable_without_adult?(date:, start_time:) ⇒ Boolean
Determines if a booking can be made without an adult.
-
#error_message ⇒ String
Returns the error message for the inventory checker service.
-
#find_available_dates(adult:, start_date:, end_date:, kids:) ⇒ Array<Date>
Finds available dates for booking based on the given parameters.
-
#find_available_single_date(adult:, date:, kids:) ⇒ Object
Finds available inventory for a single date.
-
#find_available_start_times(adult:, kids:, date:) ⇒ Array
Finds the available start times for a given date, number of adults, and number of kids.
-
#find_available_start_times_v4(adult:, kids:, date:) ⇒ Array
Finds the available start times for a given date, number of adults, and number of kids.
-
#initialize(restaurant_id, time_zone) ⇒ InvCheckerBaseService
constructor
A new instance of InvCheckerBaseService.
-
#inventory_bookable?(date:, start_time:, adult:, kids:) ⇒ Boolean
Checks if the inventory is bookable for the given date, start time, number of adults, and number of kids.
-
#package_bookable?(date:, start_time:, adult:, kids:, slug:) ⇒ Boolean
Checks if a package is bookable on a specific date and time, with given number of adults, kids, and slug.
Constructor Details
#initialize(restaurant_id, time_zone) ⇒ InvCheckerBaseService
Returns a new instance of InvCheckerBaseService.
8 9 10 11 |
# File 'app/services/inventory/inv_checker_base_service.rb', line 8 def initialize(restaurant_id, time_zone) @restaurant_id = restaurant_id @time_zone = time_zone end |
Instance Attribute Details
#restaurant_id ⇒ Object (readonly)
Returns the value of attribute restaurant_id.
6 7 8 |
# File 'app/services/inventory/inv_checker_base_service.rb', line 6 def restaurant_id @restaurant_id end |
#time_zone ⇒ Object (readonly)
Returns the value of attribute time_zone.
6 7 8 |
# File 'app/services/inventory/inv_checker_base_service.rb', line 6 def time_zone @time_zone end |
Class Method Details
.update_cache_value(restaurant_id:, restaurant_package_id: nil, restaurant_package_ids: [], reservation_level: false, restaurant_level: false, restaurant_package_level: false, dates: [], datetimes: [], reset_mode: false) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'app/services/inventory/inv_checker_base_service.rb', line 18 def self.update_cache_value(restaurant_id:, restaurant_package_id: nil, restaurant_package_ids: [], reservation_level: false, restaurant_level: false, restaurant_package_level: false, dates: [], datetimes: [], reset_mode: false) raise NotImplementedError, 'Subclasses must implement this method' end |
.warm_up_cache(restaurant_id, dates) ⇒ Object
subclass has to implement this class method to warm up the cache
14 15 16 |
# File 'app/services/inventory/inv_checker_base_service.rb', line 14 def self.warm_up_cache(restaurant_id, dates) raise NotImplementedError, 'Subclasses must implement this method' end |
Instance Method Details
#add_on_bookable?(date:, start_time:, r_add_on_id:) ⇒ Boolean
Determines if an add-on is bookable on a specific date and time.
152 153 154 |
# File 'app/services/inventory/inv_checker_base_service.rb', line 152 def add_on_bookable?(date:, start_time:, r_add_on_id:) raise NotImplementedError, 'Subclasses must implement this method' end |
#available_add_ons(date:, start_time:, r_add_on_ids:) ⇒ Array
Find available add-ons for a given date, start time, number of adults, and number of kids.
142 143 144 |
# File 'app/services/inventory/inv_checker_base_service.rb', line 142 def available_add_ons(date:, start_time:, r_add_on_ids:) raise NotImplementedError, 'Subclasses must implement this method' end |
#available_packages(date:, start_time:, adult:, kids:) ⇒ Array
Calculates the available packages for a given date, start time, number of adults, and number of kids.
87 88 89 |
# File 'app/services/inventory/inv_checker_base_service.rb', line 87 def available_packages(date:, start_time:, adult:, kids:) raise NotImplementedError, 'Subclasses must implement this method' end |
#bookable?(date:, start_time:, adult:, kids:) ⇒ Boolean
Determines if a booking is possible for the specified parameters.
44 45 46 |
# File 'app/services/inventory/inv_checker_base_service.rb', line 44 def bookable?(date:, start_time:, adult:, kids:) raise NotImplementedError, 'Subclasses must implement this method' end |
#bookable_without_adult?(date:, start_time:) ⇒ Boolean
Determines if a booking can be made without an adult.
76 77 78 |
# File 'app/services/inventory/inv_checker_base_service.rb', line 76 def bookable_without_adult?(date:, start_time:) raise NotImplementedError, 'Subclasses must implement this method' end |
#error_message ⇒ String
Returns the error message for the inventory checker service.
32 33 34 |
# File 'app/services/inventory/inv_checker_base_service.rb', line 32 def raise NotImplementedError, 'Subclasses must implement this method' end |
#find_available_dates(adult:, start_date:, end_date:, kids:) ⇒ Array<Date>
Finds available dates for booking based on the given parameters.
97 98 99 |
# File 'app/services/inventory/inv_checker_base_service.rb', line 97 def find_available_dates(adult:, start_date:, end_date:, kids:) raise NotImplementedError, 'Subclasses must implement this method' end |
#find_available_single_date(adult:, date:, kids:) ⇒ Object
Finds available inventory for a single date.
Parameters:
-
adult: The number of adult guests.
-
date: The date for which to find available inventory.
-
kids: The number of children guests.
Raises:
-
NotImplementedError: Subclasses must implement this method.
Returns: None.
112 113 114 |
# File 'app/services/inventory/inv_checker_base_service.rb', line 112 def find_available_single_date(adult:, date:, kids:) raise NotImplementedError, 'Subclasses must implement this method' end |
#find_available_start_times(adult:, kids:, date:) ⇒ Array
Finds the available start times for a given date, number of adults, and number of kids.
122 123 124 |
# File 'app/services/inventory/inv_checker_base_service.rb', line 122 def find_available_start_times(adult:, kids:, date:) raise NotImplementedError, 'Subclasses must implement this method' end |
#find_available_start_times_v4(adult:, kids:, date:) ⇒ Array
Finds the available start times for a given date, number of adults, and number of kids.
132 133 134 |
# File 'app/services/inventory/inv_checker_base_service.rb', line 132 def find_available_start_times_v4(adult:, kids:, date:) raise NotImplementedError, 'Subclasses must implement this method' end |
#inventory_bookable?(date:, start_time:, adult:, kids:) ⇒ Boolean
Checks if the inventory is bookable for the given date, start time, number of adults, and number of kids.
55 56 57 |
# File 'app/services/inventory/inv_checker_base_service.rb', line 55 def inventory_bookable?(date:, start_time:, adult:, kids:) raise NotImplementedError, 'Subclasses must implement this method' end |
#package_bookable?(date:, start_time:, adult:, kids:, slug:) ⇒ Boolean
Checks if a package is bookable on a specific date and time, with given number of adults, kids, and slug.
67 68 69 |
# File 'app/services/inventory/inv_checker_base_service.rb', line 67 def package_bookable?(date:, start_time:, adult:, kids:, slug:) raise NotImplementedError, 'Subclasses must implement this method' end |