Class: Legion::Data::Model::AuditLog
- Inherits:
-
Object
- Object
- Legion::Data::Model::AuditLog
- Includes:
- Logging::Helper
- Defined in:
- lib/legion/data/models/audit_log.rb
Constant Summary collapse
- VALID_EVENT_TYPES =
%w[runner_execution lifecycle_transition].freeze
- VALID_STATUSES =
%w[success failure denied].freeze
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Logging::Helper
Class Method Details
.compute_hash(record) ⇒ Object
38 39 40 |
# File 'lib/legion/data/models/audit_log.rb', line 38 def self.compute_hash(record) Legion::Data::AuditLogHashChain.compute_hash(record) end |
.verify_chain(records = order(:created_at, :id).all) ⇒ Object
42 43 44 |
# File 'lib/legion/data/models/audit_log.rb', line 42 def self.verify_chain(records = order(:created_at, :id).all) Legion::Data::AuditLogHashChain.verify(records) end |
Instance Method Details
#before_destroy ⇒ Object
34 35 36 |
# File 'lib/legion/data/models/audit_log.rb', line 34 def before_destroy raise 'audit_log records are immutable and cannot be deleted' end |
#before_update ⇒ Object
30 31 32 |
# File 'lib/legion/data/models/audit_log.rb', line 30 def before_update raise 'audit_log records are immutable and cannot be updated' end |
#parsed_detail ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/legion/data/models/audit_log.rb', line 21 def parsed_detail return nil unless detail Legion::JSON.load(detail) rescue StandardError => e handle_exception(e, level: :warn, handled: true, operation: :parsed_detail, id: self[:id]) nil end |
#validate ⇒ Object
15 16 17 18 19 |
# File 'lib/legion/data/models/audit_log.rb', line 15 def validate super errors.add(:event_type, 'invalid') unless VALID_EVENT_TYPES.include?(event_type) errors.add(:status, 'invalid') unless VALID_STATUSES.include?(status) end |