Class: ActiveRecord::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_ext.rb

Instance Method Summary collapse

Instance Method Details

#create_or_update_with_tracking(*args) ⇒ Object



8
9
10
11
12
13
# File 'lib/rails_ext.rb', line 8

def create_or_update_with_tracking(*args)
  new_record = new_record?
  saved = create_or_update_without_tracking(*args)
  append_instance(ActiveRecord::Base.saved_objects) if new_record && saved
  saved
end

#destroy_with_tracking(*args) ⇒ Object



16
17
18
19
20
# File 'lib/rails_ext.rb', line 16

def destroy_with_tracking(*args)
  result = destroy_without_tracking(*args)
  append_instance(ActiveRecord::Base.destroyed_objects) if result
  result
end

#validate_with_tracking(*args) ⇒ Object



23
24
25
26
27
# File 'lib/rails_ext.rb', line 23

def validate_with_tracking(*args)
  valid = validate_without_tracking(*args)
  append_instance(ActiveRecord::Base.invalid_objects) if !valid
  valid
end