Class: Agents::CreateBase
Overview
Base Class for booking creation
Direct Known Subclasses
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
#audit_comment, #errors, #executor, #force_update, #owner, #reservation, #reservation_params, #restaurant, #user, #vendor_booking_id
Instance Method Summary collapse
- #execute ⇒ Object
- #execute! ⇒ Object
-
#initialize(params_or_obj = nil) ⇒ CreateBase
constructor
A new instance of CreateBase.
- #make_booking ⇒ Object
- #make_booking! ⇒ Object
- #notification_sent? ⇒ Boolean
Methods inherited from Base
#error_message, #hotline, #inventory_available?, #save_reservation!, #status=
Methods included from SharedJobs
#give_campaign_reward, #send_rating_email
Constructor Details
#initialize(params_or_obj = nil) ⇒ CreateBase
Returns a new instance of CreateBase.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/my_lib/agents/create_base.rb', line 10 def initialize(params_or_obj = nil) @reservation = if params_or_obj.is_a? ::Reservation params_or_obj else self.vendor_booking_id = params_or_obj.delete(:vendor_booking_id) ::Reservation.new(params_or_obj) end @required_attrs = [] @notifications_sent = [] after_initialize end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Agents::Base
Instance Method Details
#execute ⇒ Object
50 51 52 |
# File 'app/my_lib/agents/create_base.rb', line 50 def execute make_booking end |
#execute! ⇒ Object
31 32 33 |
# File 'app/my_lib/agents/create_base.rb', line 31 def execute! make_booking! end |
#make_booking ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/my_lib/agents/create_base.rb', line 35 def make_booking reservation.errors.clear make_booking! true rescue InvalidReservation => e errors.add(:base, e.) false rescue ActiveRecord::ActiveRecordError => e HH_LOGGER.info e false rescue StandardError => e APMErrorHandler.report e false end |
#make_booking! ⇒ Object
27 28 29 |
# File 'app/my_lib/agents/create_base.rb', line 27 def make_booking! raise 'not implemented' end |
#notification_sent? ⇒ Boolean
23 24 25 |
# File 'app/my_lib/agents/create_base.rb', line 23 def notification_sent? @notifications_sent.flatten.length.positive? end |