module ActiveBookings::Bookable
Private Class Methods
bookable?()
click to toggle source
# File lib/active_bookings/bookable.rb, line 37 def self.bookable? true end
Public Instance Methods
bookable?()
click to toggle source
# File lib/active_bookings/bookable.rb, line 4 def bookable? false end
is_bookable(options={})
click to toggle source
Make a model bookable
Example:
class Room < ActiveRecord::Base is_bookable end
# File lib/active_bookings/bookable.rb, line 15 def is_bookable(options={}) bookable(options) end
Private Instance Methods
bookable(options)
click to toggle source
Make a model bookable
# File lib/active_bookings/bookable.rb, line 22 def bookable(options) assoc_class_name = options.delete(:class_name) || '::ActiveBookings::Booking' if bookable? self.booking_opts = options else class_attribute :booking_opts self.booking_opts = options class_eval do serialize :schedule, ActiveBookings::Serializer has_many :bookings, as: :bookable, dependent: :destroy, class_name: assoc_class_name validates_numericality_of :capacity, if: :capacity?, only_integer: true, greater_than_or_equal_to: 0 def self.bookable? true end def schedule_required? self.booking_opts && self.booking_opts && self.booking_opts[:time_type] != :none end def capacity_required? self.booking_opts && self.booking_opts[:capacity_type] != :none end end end include Core end
capacity_required?()
click to toggle source
# File lib/active_bookings/bookable.rb, line 45 def capacity_required? self.booking_opts && self.booking_opts[:capacity_type] != :none end
schedule_required?()
click to toggle source
# File lib/active_bookings/bookable.rb, line 41 def schedule_required? self.booking_opts && self.booking_opts && self.booking_opts[:time_type] != :none end