Sha256: e33ca3d1e605de60d8792c4e57e4b47370d20d0cf580d0f255dae55bbd3541ef

Contents?: true

Size: 982 Bytes

Versions: 5

Compression:

Stored size: 982 Bytes

Contents

require 'active_support/concern'
require 'active_model/observing'

module Ripple
  module Observable
    extend ActiveSupport::Concern
    include ActiveModel::Observing

    included do
      set_callback(:create, :before)     { notify_observers :before_create }
      set_callback(:create, :after)      { notify_observers :after_create }

      set_callback(:update, :before)     { notify_observers :before_update }
      set_callback(:update, :after)      { notify_observers :after_update }

      set_callback(:save, :before)       { notify_observers :before_save }
      set_callback(:save, :after)        { notify_observers :after_save }

      set_callback(:destroy, :before)    { notify_observers :before_destroy }
      set_callback(:destroy, :after)     { notify_observers :after_destroy }

      set_callback(:validation, :before) { notify_observers :before_validation }
      set_callback(:validation, :after)  { notify_observers :after_validation }
    end

  end
end

Version data entries

5 entries across 5 versions & 4 rubygems

Version Path
wyngle-ripple-0.1.0 lib/ripple/observable.rb
better-ripple-1.0.0 lib/ripple/observable.rb
ripple-1.0.0.beta2 lib/ripple/observable.rb
seomoz-ripple-1.0.0.pre lib/ripple/observable.rb
ripple-1.0.0.beta lib/ripple/observable.rb