Sha256: 325a051419e2add14bcadc230063287f502cbb1d85a1381da10a5d6f6dcfe944

Contents?: true

Size: 452 Bytes

Versions: 5

Compression:

Stored size: 452 Bytes

Contents

module OhMyLog
  class ActiveRecordObserver < ::ActiveRecord::Observer

    #this is the callback that happens every time after we made changes to the model
    def after_save(model)
      #we only add this model in the target list if this model got SUCCESSFULLY change
      must_be_logged = model.methods.include?(:saved_changes) ? model.saved_changes.empty? : model.changes.empty?
      Log::add_target(model) unless must_be_logged
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
oh_my_log-1.0.5 lib/oh_my_log/active_record_observer.rb
oh_my_log-1.0.4 lib/oh_my_log/active_record_observer.rb
oh_my_log-1.0.3 lib/oh_my_log/active_record_observer.rb
oh_my_log-1.0.2 lib/oh_my_log/active_record_observer.rb
oh_my_log-1.0.1 lib/oh_my_log/active_record_observer.rb