Class: ActiveAgent::Dashboard::AgentVersion
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ActiveAgent::Dashboard::AgentVersion
- Defined in:
- lib/active_agent/dashboard/app/models/active_agent/dashboard/agent_version.rb
Overview
Tracks version history for agent configurations.
Each time an agent’s configuration changes, a new version is created with a snapshot of the configuration at that point in time.
Instance Method Summary collapse
-
#diff(other_version) ⇒ Object
Compare two versions.
-
#initial? ⇒ Boolean
Check if this is the initial version.
-
#latest? ⇒ Boolean
Check if this is the latest version.
-
#next_version ⇒ Object
Get next version.
-
#previous ⇒ Object
Get previous version.
Methods inherited from ApplicationRecord
for_owner, owner_association, table_name
Instance Method Details
#diff(other_version) ⇒ Object
Compare two versions
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/active_agent/dashboard/app/models/active_agent/dashboard/agent_version.rb', line 26 def diff(other_version) return {} unless other_version changes = {} configuration_snapshot.each do |key, value| other_value = other_version.configuration_snapshot[key] if value != other_value changes[key] = { from: other_value, to: value } end end changes end |
#initial? ⇒ Boolean
Check if this is the initial version
55 56 57 |
# File 'lib/active_agent/dashboard/app/models/active_agent/dashboard/agent_version.rb', line 55 def initial? version_number == 1 end |
#latest? ⇒ Boolean
Check if this is the latest version
50 51 52 |
# File 'lib/active_agent/dashboard/app/models/active_agent/dashboard/agent_version.rb', line 50 def latest? agent.latest_version&.id == id end |
#next_version ⇒ Object
Get next version
45 46 47 |
# File 'lib/active_agent/dashboard/app/models/active_agent/dashboard/agent_version.rb', line 45 def next_version agent.agent_versions.where("version_number > ?", version_number).order(version_number: :asc).first end |
#previous ⇒ Object
Get previous version
40 41 42 |
# File 'lib/active_agent/dashboard/app/models/active_agent/dashboard/agent_version.rb', line 40 def previous agent.agent_versions.where("version_number < ?", version_number).order(version_number: :desc).first end |