Class: Booking

Inherits:
Slot
  • Object
show all
Defined in:
app/models/booking.rb

Overview

This represents a kind of Slot that represents the Booking that a Customer reserves with a service Provider.

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

Instance Method Summary (collapse)

Methods inherited from Slot

week

Constructor Details

- (Booking) initialize

This sets the Booking's Color and State.



39
40
41
42
43
# File 'app/models/booking.rb', line 39

def initialize(*)
  super
  self.color ||= Color.blue
  self.booking_state ||= BookingState.pending
end

Instance Method Details

- (Object) build_period(attributes = {})



45
46
47
48
49
50
51
# File 'app/models/booking.rb', line 45

def build_period(attributes = {})
  if free_slot.nil?
    super
  else
    super(attributes.merge(starts_at: free_slot.period.starts_at, ends_at: free_slot.period.ends_at))
  end
end