module ActiveBookings::Booker::ClassMethods

Public Instance Methods

booker?() click to toggle source
# File lib/active_bookings/booker.rb, line 27
def booker?
  false
end
is_booker(opts={}) click to toggle source

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
# 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