Class: BookingSerializer
- Inherits:
-
ActiveModel::Serializer
- Object
- ActiveModel::Serializer
- BookingSerializer
- Defined in:
- app/serializers/booking_serializer.rb
Instance Method Summary collapse
- #calculate_city_fee ⇒ Object
- #calculate_cleaning_fee ⇒ Object
- #calculate_totals ⇒ Object
- #check_in_date ⇒ Object
- #check_out_date ⇒ Object
- #completed_at ⇒ Object
- #extra_guest_amount ⇒ Object
- #invoice_total ⇒ Object
- #last_five_messages ⇒ Object
- #property_user ⇒ Object
- #room_count ⇒ Object
- #tax_total ⇒ Object
- #total ⇒ Object
Instance Method Details
#calculate_city_fee ⇒ Object
55 56 57 |
# File 'app/serializers/booking_serializer.rb', line 55 def calculate_city_fee object.property.city_fee end |
#calculate_cleaning_fee ⇒ Object
51 52 53 |
# File 'app/serializers/booking_serializer.rb', line 51 def calculate_cleaning_fee object.property.cleaning_fee end |
#calculate_totals ⇒ Object
27 28 29 |
# File 'app/serializers/booking_serializer.rb', line 27 def calculate_totals object.calculate_totals end |
#check_in_date ⇒ Object
11 12 13 |
# File 'app/serializers/booking_serializer.rb', line 11 def check_in_date object.check_in_date.strftime("%B %d, %Y") end |
#check_out_date ⇒ Object
15 16 17 |
# File 'app/serializers/booking_serializer.rb', line 15 def check_out_date object.check_out_date.strftime("%B %d, %Y") end |
#completed_at ⇒ Object
19 20 21 |
# File 'app/serializers/booking_serializer.rb', line 19 def completed_at object.completed_at end |
#extra_guest_amount ⇒ Object
39 40 41 |
# File 'app/serializers/booking_serializer.rb', line 39 def extra_guest_amount object.extra_guest_amount end |
#invoice_total ⇒ Object
47 48 49 |
# File 'app/serializers/booking_serializer.rb', line 47 def invoice_total object.invoice&.total end |
#last_five_messages ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/serializers/booking_serializer.rb', line 59 def return nil unless object&.chat return nil unless object&.chat&..any? = if scope&.dig(:current_user)&.stay_user? object.chat..where(event_for: [ "student", "both" ]) elsif scope&.dig(:current_user)&.stay_host? object.chat..where(event_for: [ "host", "both" ]) else object.chat. end last_five = .last(5) ActiveModelSerializers::SerializableResource.new(last_five, each_serializer: MessageSerializer) end |
#property_user ⇒ Object
43 44 45 |
# File 'app/serializers/booking_serializer.rb', line 43 def property_user object.property.user.present? ? UserListingSerializer.new(object.property.user) : nil end |
#room_count ⇒ Object
31 32 33 |
# File 'app/serializers/booking_serializer.rb', line 31 def room_count object.rooms.count end |
#tax_total ⇒ Object
35 36 37 |
# File 'app/serializers/booking_serializer.rb', line 35 def tax_total object.calculate_tax_total end |
#total ⇒ Object
23 24 25 |
# File 'app/serializers/booking_serializer.rb', line 23 def total object.total_amount end |