Module: ActiveBookings::Booker::ClassMethods
- Defined in:
- lib/active_bookings/booker.rb
Instance Method Summary collapse
- #booker? ⇒ Boolean
-
#is_booker(opts = {}) ⇒ Object
Make a model a booker.
Instance Method Details
#booker? ⇒ Boolean
27 28 29 |
# File 'lib/active_bookings/booker.rb', line 27 def booker? false end |
#is_booker(opts = {}) ⇒ Object
Make a model a booker. This allows an instance of a model to claim ownership of bookings.
Example:
class User < ActiveRecord::Base
is_booker
end
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/active_bookings/booker.rb', line 16 def is_booker(opts={}) assoc_class_name = opts.delete(:class_name) || '::ActiveBookings::Booking' class_eval do has_many :bookings, as: :booker, dependent: :destroy, class_name: assoc_class_name end include ActiveBookings::Booker::InstanceMethods extend ActiveBookings::Booker::SingletonMethods end |