class ActsAsBookable::Booking

Booking model. Store in database bookings made by bookers on bookables

Public Instance Methods

overlapped() click to toggle source

Retrieves overlapped bookings, given a bookable and some booking options

# File lib/acts_as_bookable/booking.rb, line 19
scope :overlapped, ->(bookable,opts) {
  query = where(bookable_id: bookable.id)

Private Instance Methods

bookable_must_be_bookable() click to toggle source

Validation method. Check if the bookable resource is actually bookable

# File lib/acts_as_bookable/booking.rb, line 39
def bookable_must_be_bookable
  if bookable.present? && !bookable.class.bookable?
    errors.add(:bookable, T.er('booking.bookable_must_be_bookable', model: bookable.class.to_s))
  end
end
booker_must_be_booker() click to toggle source

Validation method. Check if the booker model is actually a booker

# File lib/acts_as_bookable/booking.rb, line 48
def booker_must_be_booker
  if booker.present? && !booker.class.booker?
    errors.add(:booker, T.er('booking.booker_must_be_booker', model: booker.class.to_s))
  end
end