Class: ActsAsBookable::Booking
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ActsAsBookable::Booking
- Defined in:
- lib/acts_as_bookable/booking.rb
Overview
Booking model. Store in database bookings made by bookers on bookables
Instance Method Summary collapse
-
#overlapped ⇒ Object
Retrieves overlapped bookings, given a bookable and some booking options.
Instance Method Details
#overlapped ⇒ Object
Retrieves overlapped bookings, given a bookable and some booking options
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/acts_as_bookable/booking.rb', line 19 scope :overlapped, ->(bookable,opts) { query = where(bookable_id: bookable.id) # Time options if(opts[:time].present?) query = DBUtils.time_comparison(query,'time','=',opts[:time]) end if(opts[:time_start].present?) query = DBUtils.time_comparison(query,'time_end', '>=', opts[:time_start]) end if(opts[:time_end].present?) query = DBUtils.time_comparison(query,'time_start', '<', opts[:time_end]) end query } |