Class: Slot

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/slot.rb

Overview

The abstract concept of a Slot, which can be specialized in FreeSlots or Bookings. A booking is drawn over a free slot in the UI.

Schema Information

Table name: slots

id                 :integer          not null, primary key
capacity           :integer          default("1")
min_booking_length :integer          default("15")
created_at         :datetime         not null
updated_at         :datetime         not null
slot_group_id      :integer
color_id           :integer          not null
type               :string           not null
provider_id        :integer
booking_state_id   :integer
period_id          :integer          not null
affiliation_id     :integer
free_slot_id       :integer

Direct Known Subclasses

Booking, FreeSlot

Instance Method Summary (collapse)

Constructor Details

- (Slot) initialize

Returns a new instance of Slot



37
38
39
40
# File 'app/models/slot.rb', line 37

def initialize(*)
  super
  self.period ||= build_period
end

Instance Method Details

- (Object) respects_min_booking_length



42
43
44
45
46
# File 'app/models/slot.rb', line 42

def respects_min_booking_length
  if period.length < min_booking_length.minutes
    errors.add :period, "Period does not respect minimum booking length."
  end
end