Module: Journaled::Changes

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/journaled/changes.rb

Instance Method Summary collapse

Instance Method Details

#delete(force: false) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/models/concerns/journaled/changes.rb', line 31

def delete(force: false)
  if force || self.class.journaled_attribute_names.empty?
    super()
  else
    raise("      #delete aborted by Journaled::Changes.\n\n      Call #destroy instead to ensure journaling or invoke #delete(force: true)\n      to override and skip journaling.\n    ERROR\n  end\nend\n")

#update_columns(attributes, opts = { force: false }) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/models/concerns/journaled/changes.rb', line 44

def update_columns(attributes, opts = { force: false })
  unless opts[:force] || self.class.journaled_attribute_names.empty?
    conflicting_journaled_attribute_names = self.class.journaled_attribute_names & attributes.keys.map(&:to_sym)
    raise("      #update_columns aborted by Journaled::Changes due to journaled attributes:\n\n        \#{conflicting_journaled_attribute_names.join(', ')}\n\n      Call #update instead to ensure journaling or invoke #update_columns\n      with additional arg `{ force: true }` to override and skip journaling.\n    ERROR\n  end\n  super(attributes)\nend\n") if conflicting_journaled_attribute_names.present?