Module: Sequel::Plugins::HasPaperTrail::InstanceMethods
- Defined in:
- lib/sequel/plugins/has_paper_trail.rb
Overview
rubocop:disable Style/Documentation
Instance Method Summary collapse
Instance Method Details
#after_create ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/sequel/plugins/has_paper_trail.rb', line 50 def after_create super return unless SequelPaperTrail.enabled? object_changes = values.each_with_object({}) { |(k, v), acc| acc[k] = [nil, v] } attrs = { item_id: id, event: :create, object_changes: object_changes.to_json, object: nil } PaperTrailHelpers.create_version(model, attrs) end |
#after_destroy ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/sequel/plugins/has_paper_trail.rb', line 83 def after_destroy super return unless SequelPaperTrail.enabled? attrs = { item_id: id, event: :destroy, object_changes: nil, object: values.to_json } PaperTrailHelpers.create_version(model, attrs) end |
#after_update ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/sequel/plugins/has_paper_trail.rb', line 67 def after_update super return unless SequelPaperTrail.enabled? return if column_changes.empty? attrs = { item_id: id, event: :update, object_changes: column_changes.to_json, object: values.merge(initial_values).to_json } PaperTrailHelpers.create_version(model, attrs) end |