Class: BigGroupChecker
- Inherits:
-
Object
- Object
- BigGroupChecker
- Includes:
- DefaultErrorContainer
- Defined in:
- app/my_lib/big_group_checker.rb
Overview
typed: ignore Helper class to check big group requirement is it allowed or not
Instance Method Summary collapse
- #can_be_applied?(restaurant, date, party_size) ⇒ Boolean
- #maybe_can_be_applied?(adult, _kids) ⇒ Boolean
Methods included from DefaultErrorContainer
#error, #error_message_simple, #merge_errors
Instance Method Details
#can_be_applied?(restaurant, date, party_size) ⇒ Boolean
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/my_lib/big_group_checker.rb', line 6 def can_be_applied?(restaurant, date, party_size) errors.clear today = Time.now_in_tz(restaurant.time_zone).to_date days_in_advance = (date - today).to_i errors.add :base, 'Promotion for this restaurant has been expired' unless restaurant.active? if party_size.to_i < min_party_size errors.add :base, "Minimum party size for big group booking is #{min_party_size}" end restaurant_days_in_advance = restaurant.days_in_advance if days_in_advance > restaurant_days_in_advance errors.add :base, "This restaurant only accept booking until #{restaurant_days_in_advance} days in advance" end errors.blank? end |
#maybe_can_be_applied?(adult, _kids) ⇒ Boolean
25 26 27 28 29 |
# File 'app/my_lib/big_group_checker.rb', line 25 def maybe_can_be_applied?(adult, _kids) errors.clear errors.add :base, "Minimum party size for big group booking is #{min_party_size}" if adult.to_i < min_party_size errors.blank? end |