Class: PackageServices::DynamicPricings
- Inherits:
-
Object
- Object
- PackageServices::DynamicPricings
- Defined in:
- app/services/package_services/dynamic_pricings.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#restaurant ⇒ Object
readonly
Returns the value of attribute restaurant.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
Instance Method Summary collapse
-
#initialize(params, restaurant) ⇒ DynamicPricings
constructor
Initializes the service with parameters and restaurant.
-
#process ⇒ void
Processes the dynamic pricing calculation flow.
Constructor Details
#initialize(params, restaurant) ⇒ DynamicPricings
Initializes the service with parameters and restaurant.
28 29 30 31 32 33 34 |
# File 'app/services/package_services/dynamic_pricings.rb', line 28 def initialize(params, restaurant) @params = params @restaurant = restaurant @message = '' @success = false @data = [] end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
22 23 24 |
# File 'app/services/package_services/dynamic_pricings.rb', line 22 def data @data end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
22 23 24 |
# File 'app/services/package_services/dynamic_pricings.rb', line 22 def @message end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
22 23 24 |
# File 'app/services/package_services/dynamic_pricings.rb', line 22 def params @params end |
#restaurant ⇒ Object (readonly)
Returns the value of attribute restaurant.
22 23 24 |
# File 'app/services/package_services/dynamic_pricings.rb', line 22 def restaurant @restaurant end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
22 23 24 |
# File 'app/services/package_services/dynamic_pricings.rb', line 22 def success @success end |
Instance Method Details
#process ⇒ void
This method returns an undefined value.
Processes the dynamic pricing calculation flow. Calls methods to filter packages, calculate pricing, and build the response result.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/services/package_services/dynamic_pricings.rb', line 40 def process filter_packages calculate_packages build_result rescue ActiveRecord::RecordNotFound raise RecordNotFoundButOk rescue InvalidPackageData => e @message = e. @success = false rescue Date::Error => e @message = e. @success = false rescue StandardError => e handle_error(e) end |