Module: HhPackage::ModelConcerns::MixAndMatch
- Extended by:
- ActiveSupport::Concern
- Included in:
- Package::Base
- Defined in:
- app/models/concerns/hh_package/model_concerns/mix_and_match.rb
Constant Summary collapse
- MINIMUM_MIX_AND_MATCH =
2
Instance Method Summary collapse
-
#allow_mix_and_match? ⇒ Boolean
this method is used to determine whether user can mix and match the package.
- #allow_mix_ayce? ⇒ Boolean
-
#mix_n_match_qty(adult, quantity, package_count) ⇒ Object
this is a helper method to determine the quantity of the package if the package is a mix and match package or other package type such as Party Pack, then the quantity will be the same as the package_count otherwise, the quantity will be the same as the adult quantity.
-
#use_mix_and_match?(package_count) ⇒ Boolean
(also: #valid_to_use_mix_and_match?)
this method is used to determine whether use mix and match or not.
Instance Method Details
#allow_mix_and_match? ⇒ Boolean
this method is used to determine whether user can mix and match the package
9 10 11 |
# File 'app/models/concerns/hh_package/model_concerns/mix_and_match.rb', line 9 def allow_mix_and_match? package_attr&.allow_mix? end |
#allow_mix_ayce? ⇒ Boolean
13 14 15 |
# File 'app/models/concerns/hh_package/model_concerns/mix_and_match.rb', line 13 def allow_mix_ayce? instance_of?(HhPackage::Package::Ayce) && allow_mix_and_match? end |
#mix_n_match_qty(adult, quantity, package_count) ⇒ Object
this is a helper method to determine the quantity of the package if the package is a mix and match package or other package type such as Party Pack, then the quantity will be the same as the package_count otherwise, the quantity will be the same as the adult quantity
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/models/concerns/hh_package/model_concerns/mix_and_match.rb', line 30 def mix_n_match_qty(adult, quantity, package_count) case self.class.name when 'HhPackage::Package::Ayce' if use_mix_and_match?(package_count) quantity else adult end else quantity end end |
#use_mix_and_match?(package_count) ⇒ Boolean Also known as: valid_to_use_mix_and_match?
this method is used to determine whether use mix and match or not
18 19 20 |
# File 'app/models/concerns/hh_package/model_concerns/mix_and_match.rb', line 18 def use_mix_and_match?(package_count) package_count >= MINIMUM_MIX_AND_MATCH && allow_mix_and_match? end |