Class: Schedule
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Schedule
- Defined in:
- app/models/schedule.rb
Overview
== Schema Information
Table name: schedules
Database name: primary
id :integer not null, primary key
count :integer
date :date
day :text
day_of_week :text
interval :string
rule :string
schedulable_type :string
time :time
until :datetime
created_at :datetime
updated_at :datetime
schedulable_id :integer
A recurrence rule attached to a schedulable record (see Schedulable).
Vendored from the schedulable gem's Schedulable::Model::Schedule base
class. rule selects the recurrence kind (singular, daily, weekly,
monthly); the matching IceCube::Schedule is rebuilt on every load and
save, and unknown method calls delegate to it.
Constant Summary
Constants included from Schedulable
Schedulable::SIMPLE_FORM_OPTIONS
Instance Attribute Summary collapse
- #date ⇒ Object readonly
- #rule ⇒ Object readonly
-
#time ⇒ Time?
readonly
Normalizes the AR
timevalue to a coreTime.
Belongs to collapse
Class Method Summary collapse
-
.param_names ⇒ Array
Strong-parameter shape for a nested schedule form.
Instance Method Summary collapse
-
#to_icecube ⇒ IceCube::Schedule?
The underlying recurrence schedule.
-
#to_s ⇒ String
A localized, human-readable description of the schedule.
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Schedulable
Methods included from Models::AfterCommittable
Methods included from Models::EventPublishable
Instance Attribute Details
#date ⇒ Object (readonly)
40 |
# File 'app/models/schedule.rb', line 40 validates :date, presence: true, if: -> { rule == 'singular' } |
#rule ⇒ Object (readonly)
38 |
# File 'app/models/schedule.rb', line 38 validates :rule, presence: true |
#time ⇒ Time? (readonly)
Normalizes the AR time value to a core Time.
ActiveRecord maps time columns to ActiveSupport::TimeWithZone;
callers (and the recurrence builder) expect a plain Time.
52 |
# File 'app/models/schedule.rb', line 52 validates :time, presence: true |
Class Method Details
.param_names ⇒ Array
Strong-parameter shape for a nested schedule form.
82 83 84 85 86 87 88 89 90 |
# File 'app/models/schedule.rb', line 82 def self.param_names [ :id, :date, :time, :time_end, :rule, :until, :count, :interval, { day: [], day_of_week: { monday: [], tuesday: [], wednesday: [], thursday: [], friday: [], saturday: [], sunday: [] } } ] end |
Instance Method Details
#schedulable ⇒ Schedulable
33 |
# File 'app/models/schedule.rb', line 33 belongs_to :schedulable, polymorphic: true |
#to_icecube ⇒ IceCube::Schedule?
Returns the underlying recurrence schedule.
65 66 67 |
# File 'app/models/schedule.rb', line 65 def to_icecube @schedule end |
#to_s ⇒ String
Returns a localized, human-readable description of the schedule.
70 71 72 73 74 75 76 77 |
# File 'app/models/schedule.rb', line 70 def to_s if rule == 'singular' datetime = date.to_datetime + time.seconds_since_midnight.seconds I18n.localize(datetime, format: :long) else to_icecube.to_s end end |