Class: ActionAgent::AgentVersion
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ActionAgent::AgentVersion
- Defined in:
- app/models/action_agent/agent_version.rb
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
Instance Method Details
#diff(other_version) ⇒ Object
Compare two versions
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/models/action_agent/agent_version.rb', line 15 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
44 45 46 |
# File 'app/models/action_agent/agent_version.rb', line 44 def initial? version_number == 1 end |
#latest? ⇒ Boolean
Check if this is the latest version
39 40 41 |
# File 'app/models/action_agent/agent_version.rb', line 39 def latest? agent.latest_version&.id == id end |
#next_version ⇒ Object
Get next version
34 35 36 |
# File 'app/models/action_agent/agent_version.rb', line 34 def next_version agent.agent_versions.where("version_number > ?", version_number).order(version_number: :asc).first end |
#previous ⇒ Object
Get previous version
29 30 31 |
# File 'app/models/action_agent/agent_version.rb', line 29 def previous agent.agent_versions.where("version_number < ?", version_number).order(version_number: :desc).first end |