Sha256: 0fe872ae94a184a7d3e5321e74c511127a883542ac267c96cbe049d6268fffb2

Contents?: true

Size: 443 Bytes

Versions: 5

Compression:

Stored size: 443 Bytes

Contents

module OhMyLog
  class MongoidObserver < ::Mongoid::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 changed
      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/mongoid_observer.rb
oh_my_log-1.0.4 lib/oh_my_log/mongoid_observer.rb
oh_my_log-1.0.3 lib/oh_my_log/mongoid_observer.rb
oh_my_log-1.0.2 lib/oh_my_log/mongoid_observer.rb
oh_my_log-1.0.1 lib/oh_my_log/mongoid_observer.rb