Sha256: 7e68c666a2e6c1d9397c901cdee00cbb9a24145048b5f8d5449f5fa273d51bae

Contents?: true

Size: 1.22 KB

Versions: 50

Compression:

Stored size: 1.22 KB

Contents

module MongoModel
  module DocumentExtensions
    module Callbacks
      extend ActiveSupport::Concern
      
      included do
        [:instantiate, :create_or_update, :create, :update, :destroy].each do |method|
          alias_method_chain method, :callbacks
        end
      end
      
      def instantiate_with_callbacks(*args) #:nodoc:
        instantiate_without_callbacks(*args)
        run_callbacks_with_embedded(:find)
      end
      private :instantiate_with_callbacks

      def create_or_update_with_callbacks #:nodoc:
        run_callbacks_with_embedded(:save) do
          create_or_update_without_callbacks
        end
      end
      private :create_or_update_with_callbacks

      def create_with_callbacks #:nodoc:
        run_callbacks_with_embedded(:create) do
          create_without_callbacks
        end
      end
      private :create_with_callbacks

      def update_with_callbacks(*args) #:nodoc:
        run_callbacks_with_embedded(:update) do
          update_without_callbacks(*args)
        end
      end
      private :update_with_callbacks

      def destroy_with_callbacks #:nodoc:
        run_callbacks_with_embedded(:destroy) do
          destroy_without_callbacks
        end
      end
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
mongomodel-0.5.5 lib/mongomodel/document/callbacks.rb
mongomodel-0.5.4 lib/mongomodel/document/callbacks.rb
mongomodel-0.5.3 lib/mongomodel/document/callbacks.rb
mongomodel-0.5.2 lib/mongomodel/document/callbacks.rb
mongomodel-0.5.1 lib/mongomodel/document/callbacks.rb
mongomodel-0.5.0 lib/mongomodel/document/callbacks.rb
mongomodel-0.4.9 lib/mongomodel/document/callbacks.rb
mongomodel-0.4.8 lib/mongomodel/document/callbacks.rb
mongomodel-0.4.7 lib/mongomodel/document/callbacks.rb
mongomodel-0.4.6 lib/mongomodel/document/callbacks.rb
mongomodel-0.4.5 lib/mongomodel/document/callbacks.rb
mongomodel-0.4.4 lib/mongomodel/document/callbacks.rb
mongomodel-0.4.3 lib/mongomodel/document/callbacks.rb
mongomodel-0.4.2 lib/mongomodel/document/callbacks.rb
mongomodel-0.4.1 lib/mongomodel/document/callbacks.rb
mongomodel-0.4.0 lib/mongomodel/document/callbacks.rb
mongomodel-0.3.6 lib/mongomodel/document/callbacks.rb
mongomodel-0.3.5 lib/mongomodel/document/callbacks.rb
mongomodel-0.3.4 lib/mongomodel/document/callbacks.rb
mongomodel-0.3.3 lib/mongomodel/document/callbacks.rb