Class: ReviewService::SecondStep
- Inherits:
-
ApplicationService
- Object
- ApplicationService
- ReviewService::SecondStep
- Defined in:
- app/services/review_service/second_step.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Attributes inherited from ApplicationService
Instance Method Summary collapse
- #error_message_simple ⇒ Object
- #execute! ⇒ Object
-
#initialize(review_id, params) ⇒ SecondStep
constructor
A new instance of SecondStep.
- #next_step_path ⇒ Object
Methods inherited from ApplicationService
Constructor Details
#initialize(review_id, params) ⇒ SecondStep
Returns a new instance of SecondStep.
10 11 12 13 |
# File 'app/services/review_service/second_step.rb', line 10 def initialize(review_id, params) self.object = Review.find(review_id) @params = params end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
8 9 10 |
# File 'app/services/review_service/second_step.rb', line 8 def params @params end |
Instance Method Details
#error_message_simple ⇒ Object
36 37 38 |
# File 'app/services/review_service/second_step.rb', line 36 def object.errors&.&.to_sentence end |
#execute! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/services/review_service/second_step.rb', line 15 def execute! success = false ActiveRecord::Base.transaction do update_review assign_review_recommended_fors assign_review_photos object.save! if object.reservation.restaurant.eligible_for_rewards? GiveReservationRewardWorker.perform_async(object.reservation_id) end success = true end raise unless success ServiceResult.new data: object end |
#next_step_path ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/services/review_service/second_step.rb', line 40 def next_step_path if user.present? url_helper.booking_review_landing_page_path(locale: MyLocaleManager.normalize_locale, customer: :member, booking_id: booking_id, review_id: object.encrypted_id) elsif opt_in_to_be_member? url_helper.booking_review_new_account_path(locale: MyLocaleManager.normalize_locale, booking_id: booking_id, review_id: object.encrypted_id) else url_helper.booking_review_landing_page_path(locale: MyLocaleManager.normalize_locale, customer: :guest, booking_id: booking_id, review_id: object.encrypted_id) end end |