🪞 Aeon::Schedulable – 4 + 1 Architecture¶
Lets any model become a keeper of time.
1️⃣ Logical View¶
Purpose:
Aeon::Schedulable is a Rails concern that grants host models the ability to attach schedules.
It defines the has_one_schedule DSL and dynamically builds associations for timestamps.
Responsibilities
- Generate one or more has_one :aeon_timestamp associations per symbol.
- Accept nested attributes for mass assignment.
- Expose helper methods (*_schedule, *_schedule_attributes=).
- Delegate to_period and next_occurrence for ease of access.
2️⃣ Process View¶
- Developer includes the concern:
ruby include Aeon::Schedulable has_one_schedule :event has_one_schedule :deadline - Rails dynamically builds:
has_one :event_schedule, class_name: "Aeon::Timestamp", as: :schedulableaccepts_nested_attributes_for :event_schedule- When model saves, nested attributes create or update Aeon::Timestamp.
- Timestamp changes trigger CacheInvalidation → Refresher → Timekeeper updates.
3️⃣ Development View¶
File: app/models/concerns/aeon/schedulable.rb
module Aeon::Schedulable
extend ActiveSupport::Concern
class_methods do
def has_one_schedule(name)
assoc = "#{name}_schedule"
has_one assoc.to_sym,
as: :schedulable,
class_name: "Aeon::Timestamp",
dependent: :destroy
accepts_nested_attributes_for assoc.to_sym
define_method(name) { send(assoc)&.to_period }
end
end
end
4️⃣ Physical View¶
| Attribute | Description |
|---|---|
| Layer | ApplicationModel (Rails) |
| Store | Postgres (via Aeon::Timestamp) |
| Dependencies | Aeon::Timestamp, ActiveRecord |
| Observability | Argus aeon.schedulable.attached |
➕ 1 Scenario View¶
Scenario A: Attaching to Task¶
class Task < ApplicationRecord
include Aeon::Schedulable
has_one_schedule :deadline
end
→ task.deadline_schedule automatically available.
Scenario B: Multiple Schedules¶
A Project can define both kickoff_schedule and review_schedule.
Security:
Nested attribute mass assignment is scoped to trusted contexts only.
Metrics:
aeon_schedulable_associations_total.