Sha256: dbba80ca5fb99cd8b9a79a3b07e9d9c665b76688596b89b20b6bc4b3982ee1fb

Contents?: true

Size: 498 Bytes

Versions: 7

Compression:

Stored size: 498 Bytes

Contents

module CallbacksHelper
  extend ActiveSupport::Concern

  included do
    [ :before_create,  :after_create,
      :before_update,  :after_update,
      :before_save,    :after_save,
      :before_destroy, :after_destroy].each do |callback|
      callback_method = "#{callback}_callback"
      send(callback, callback_method)
      define_method(callback_method) { history << callback.to_sym }
    end
  end

  def history
    @history ||= []
  end

  def clear_history
    @history = nil
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
toystore-mongo-0.12.0 spec/support/callbacks_helper.rb
toystore-mongo-0.11.0 spec/support/callbacks_helper.rb
toystore-mongo-0.10.0 spec/support/callbacks_helper.rb
toystore-mongo-0.9.0 spec/support/callbacks_helper.rb
toystore-mongo-0.8.2 spec/support/callbacks_helper.rb
toystore-mongo-0.8.1 spec/support/callbacks_helper.rb
toystore-mongo-0.8.0 spec/support/callbacks_helper.rb