Class: AddOnServices::Processor
- Inherits:
-
Object
- Object
- AddOnServices::Processor
- Defined in:
- app/services/add_on_services/processor.rb
Overview
The Processor class is responsible for processing add_ons and validating mix-and-match options for a given restaurant.
Instance Attribute Summary collapse
-
#add_on_bought ⇒ Hash
readonly
The parameters of the add_ons that were bought.
-
#add_on_data ⇒ Object
readonly
Returns the value of attribute add_on_data.
-
#adult ⇒ Object
readonly
Returns the value of attribute adult.
-
#restaurant ⇒ Object
readonly
Returns the value of attribute restaurant.
Instance Method Summary collapse
-
#initialize(params_add_on_bought, restaurant = nil, adult = nil) ⇒ Processor
constructor
Initializes a new Processor object to handle the add-on processing.
-
#process_add_ons ⇒ Array
Processes the bought add_ons and checks if they are valid for mix-and-match.
Constructor Details
#initialize(params_add_on_bought, restaurant = nil, adult = nil) ⇒ Processor
Initializes a new Processor object to handle the add-on processing.
26 27 28 29 30 |
# File 'app/services/add_on_services/processor.rb', line 26 def initialize(params_add_on_bought, restaurant = nil, adult = nil) @add_on_data = params_add_on_bought[:add_ons] || params_add_on_bought['add_on_bought'] || params_add_on_bought[:add_on_bought] || [] @restaurant = restaurant @adult = adult.to_i end |
Instance Attribute Details
#add_on_bought ⇒ Hash (readonly)
Returns the parameters of the add_ons that were bought.
12 |
# File 'app/services/add_on_services/processor.rb', line 12 attr_reader :add_on_data |
#add_on_data ⇒ Object (readonly)
Returns the value of attribute add_on_data.
12 13 14 |
# File 'app/services/add_on_services/processor.rb', line 12 def add_on_data @add_on_data end |
#adult ⇒ Object (readonly)
Returns the value of attribute adult.
20 21 22 |
# File 'app/services/add_on_services/processor.rb', line 20 def adult @adult end |
#restaurant ⇒ Object (readonly)
Returns the value of attribute restaurant.
16 17 18 |
# File 'app/services/add_on_services/processor.rb', line 16 def restaurant @restaurant end |
Instance Method Details
#process_add_ons ⇒ Array
Processes the bought add_ons and checks if they are valid for mix-and-match.
39 40 41 42 43 |
# File 'app/services/add_on_services/processor.rb', line 39 def process_add_ons add_on_data.map do |param| process_single_add_on(param) end end |