Class: PackageServices::Processor
- Inherits:
-
Object
- Object
- PackageServices::Processor
- Defined in:
- app/services/package_services/processor.rb
Overview
The Processor class is responsible for processing packages and validating mix-and-match options for a given restaurant.
Instance Attribute Summary collapse
-
#adult ⇒ Object
readonly
Returns the value of attribute adult.
-
#is_valid_mix_n_match ⇒ Object
readonly
Returns the value of attribute is_valid_mix_n_match.
-
#package_bought ⇒ Hash
readonly
The parameters of the packages that were bought.
-
#package_data ⇒ Object
readonly
Returns the value of attribute package_data.
-
#restaurant ⇒ Object
readonly
Returns the value of attribute restaurant.
Instance Method Summary collapse
-
#initialize(params_package_bought, restaurant = nil, adult = nil) ⇒ Processor
constructor
Initializes a new Processor object to handle the package processing.
-
#process_packages ⇒ Array
Processes the bought packages and checks if they are valid for mix-and-match.
Constructor Details
#initialize(params_package_bought, restaurant = nil, adult = nil) ⇒ Processor
Initializes a new Processor object to handle the package processing.
30 31 32 33 34 35 |
# File 'app/services/package_services/processor.rb', line 30 def initialize(params_package_bought, restaurant = nil, adult = nil) @package_data = params_package_bought[:packages] || params_package_bought['package_bought'] || params_package_bought[:package_bought] || [] @restaurant = restaurant @is_valid_mix_n_match = true @adult = adult.to_i end |
Instance Attribute Details
#adult ⇒ Object (readonly)
Returns the value of attribute adult.
24 25 26 |
# File 'app/services/package_services/processor.rb', line 24 def adult @adult end |
#is_valid_mix_n_match ⇒ Object (readonly)
Returns the value of attribute is_valid_mix_n_match.
20 21 22 |
# File 'app/services/package_services/processor.rb', line 20 def is_valid_mix_n_match @is_valid_mix_n_match end |
#package_bought ⇒ Hash (readonly)
Returns the parameters of the packages that were bought.
12 |
# File 'app/services/package_services/processor.rb', line 12 attr_reader :package_data |
#package_data ⇒ Object (readonly)
Returns the value of attribute package_data.
12 13 14 |
# File 'app/services/package_services/processor.rb', line 12 def package_data @package_data end |
#restaurant ⇒ Object (readonly)
Returns the value of attribute restaurant.
16 17 18 |
# File 'app/services/package_services/processor.rb', line 16 def restaurant @restaurant end |
Instance Method Details
#process_packages ⇒ Array
Processes the bought packages and checks if they are valid for mix-and-match.
44 45 46 47 48 49 |
# File 'app/services/package_services/processor.rb', line 44 def process_packages package_bought = package_data.map do |param| process_single_package(param) end [package_bought, is_valid_mix_n_match] end |