Module: PackageBooking::Components::ViewDecorator
- Includes:
- Modules::Reservations::Packages
- Included in:
- Owners::Create, Owners::Update, Users::Update
- Defined in:
- app/my_lib/package_booking/components/view_decorator.rb
Overview
Responsible to decorate reservation data to be displayed in View
Instance Method Summary collapse
- #origin_selected_packages ⇒ Object
-
#reservation_attributes ⇒ Object
public reservation attributes that can be seen by owner.
- #selected_packages ⇒ Object
-
#state ⇒ Object
used by form to render selected status.
Instance Method Details
#origin_selected_packages ⇒ Object
21 |
# File 'app/my_lib/package_booking/components/view_decorator.rb', line 21 alias origin_selected_packages selected_packages |
#reservation_attributes ⇒ Object
public reservation attributes that can be seen by owner
10 11 12 13 14 15 16 17 18 19 |
# File 'app/my_lib/package_booking/components/view_decorator.rb', line 10 def reservation_attributes attrs = { start_time: reservation.start_time_format } %I[id restaurant_id name date phone email adult kids special_request arrived group_booking active no_show table note].each do |attr| attrs[attr] = reservation.send(attr) end attrs[:state] = state attrs[:guests] = reservation.guests || [] attrs[:selected_packages] = selected_packages attrs end |
#selected_packages ⇒ Object
23 24 25 |
# File 'app/my_lib/package_booking/components/view_decorator.rb', line 23 def selected_packages origin_selected_packages(reservation) end |
#state ⇒ Object
used by form to render selected status
28 29 30 31 32 33 34 35 36 |
# File 'app/my_lib/package_booking/components/view_decorator.rb', line 28 def state [ [I18n.t('views.booking.pending_arrival'), 'pending'], [I18n.t('views.booking.pending_confirmation'), 'non_instant'], [I18n.t('views.booking.arrived').titleize, 'arrive'], [I18n.t('views.booking.cancel'), 'cancel'], [I18n.t('views.booking.no_show'), 'no_show'] ].select { |s| s[0] == reservation.status }.first.try(:last) end |