Module: ActsAsBookable::Booker::InstanceMethods
- Defined in:
- lib/acts_as_bookable/booker.rb
Instance Method Summary collapse
-
#book!(bookable, opts = {}) ⇒ Object
Book a bookable model.
- #booker? ⇒ Boolean
Instance Method Details
#book!(bookable, opts = {}) ⇒ Object
Book a bookable model
Example:
@user.book!(@room)
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/acts_as_bookable/booker.rb', line 42 def book!(bookable, opts={}) # check availability bookable.check_availability!(opts) if bookable.class.bookable? # create the new booking booking_params = opts.merge({booker: self, bookable: bookable}) booking = ActsAsBookable::Booking.create!(booking_params) # reload the bookable to make changes available bookable.reload self.reload booking end |
#booker? ⇒ Boolean
56 57 58 |
# File 'lib/acts_as_bookable/booker.rb', line 56 def booker? self.class.booker? end |