Class: SchedulerProfile
Overview
== Schema Information
Table name: scheduler_profiles
Database name: primary
id :bigint not null, primary key
buffer_after_lunch_minutes :integer default(0), not null
buffer_before_lunch_minutes :integer default(0), not null
buffer_end_of_day_minutes :integer default(0), not null
buffer_start_of_day_minutes :integer default(0), not null
max_bookings_per_day :jsonb not null
scheduler_enabled :boolean default(FALSE), not null
slug :string not null
timezone :string default("America/Chicago"), not null
created_at :datetime not null
updated_at :datetime not null
employee_id :bigint not null
Indexes
index_scheduler_profiles_on_employee_id (employee_id) UNIQUE
index_scheduler_profiles_on_scheduler_enabled (scheduler_enabled)
index_scheduler_profiles_on_slug (slug) UNIQUE
Foreign Keys
fk_rails_... (employee_id => parties.id) ON DELETE => cascade
Constant Summary
collapse
- BUFFER_OPTIONS =
[0, 15, 30, 45, 60, 90, 120].freeze
- MAX_BOOKINGS_OPTIONS =
[nil, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
#publish_event
Instance Attribute Details
#buffer_after_lunch_minutes ⇒ Object
40
41
42
|
# File 'app/models/scheduler_profile.rb', line 40
validates :buffer_start_of_day_minutes, :buffer_end_of_day_minutes,
:buffer_before_lunch_minutes, :buffer_after_lunch_minutes,
numericality: { only_integer: true, greater_than_or_equal_to: 0 }
|
#buffer_before_lunch_minutes ⇒ Object
40
41
42
|
# File 'app/models/scheduler_profile.rb', line 40
validates :buffer_start_of_day_minutes, :buffer_end_of_day_minutes,
:buffer_before_lunch_minutes, :buffer_after_lunch_minutes,
numericality: { only_integer: true, greater_than_or_equal_to: 0 }
|
#buffer_end_of_day_minutes ⇒ Object
40
41
42
|
# File 'app/models/scheduler_profile.rb', line 40
validates :buffer_start_of_day_minutes, :buffer_end_of_day_minutes,
:buffer_before_lunch_minutes, :buffer_after_lunch_minutes,
numericality: { only_integer: true, greater_than_or_equal_to: 0 }
|
#buffer_start_of_day_minutes ⇒ Object
40
41
42
|
# File 'app/models/scheduler_profile.rb', line 40
validates :buffer_start_of_day_minutes, :buffer_end_of_day_minutes,
:buffer_before_lunch_minutes, :buffer_after_lunch_minutes,
numericality: { only_integer: true, greater_than_or_equal_to: 0 }
|
#employee_id ⇒ Object
37
|
# File 'app/models/scheduler_profile.rb', line 37
validates :employee_id, uniqueness: true
|
#slug ⇒ Object
38
39
|
# File 'app/models/scheduler_profile.rb', line 38
validates :slug, presence: true, uniqueness: true,
format: { with: /\A[a-z0-9]+(?:-[a-z0-9]+)*\z/, message: 'only lowercase letters, numbers, and hyphens' }
|
Instance Method Details
35
|
# File 'app/models/scheduler_profile.rb', line 35
belongs_to :employee
|
#max_bookings_for_wday(wday) ⇒ Object
49
50
51
52
53
54
|
# File 'app/models/scheduler_profile.rb', line 49
def max_bookings_for_wday(wday)
return nil unless has_attribute?(:max_bookings_per_day)
value = max_bookings_per_day[wday.to_s]
value.present? ? value.to_i : nil
end
|
#max_bookings_per_day=(hash) ⇒ Object
56
57
58
59
60
61
62
63
|
# File 'app/models/scheduler_profile.rb', line 56
def max_bookings_per_day=(hash)
return unless has_attribute?(:max_bookings_per_day)
cleaned = hash.each_with_object({}) do |(k, v), h|
h[k.to_s] = v.present? ? v.to_i : nil
end
super(cleaned)
end
|
#should_generate_new_friendly_id? ⇒ Boolean
65
66
67
|
# File 'app/models/scheduler_profile.rb', line 65
def should_generate_new_friendly_id?
slug.blank?
end
|