Sha256: a707bdee5fa9be3241a11e58da017afbf7ae1d75668205c83a22483f972554a4

Contents?: true

Size: 1.09 KB

Versions: 52

Compression:

Stored size: 1.09 KB

Contents

module Neo4j
  module Shared
    module Callbacks #:nodoc:
      extend ActiveSupport::Concern

      module ClassMethods
        include ActiveModel::Callbacks
      end

      included do
        include ActiveModel::Validations::Callbacks
        define_model_callbacks :initialize, :find, only: :after
        define_model_callbacks :save, :create, :update, :destroy
      end

      def destroy #:nodoc:
        tx = Neo4j::Transaction.new
        run_callbacks(:destroy) { super }
      rescue
        @_deleted = false
        @attributes = @attributes.dup
        tx.mark_failed
        raise
      ensure
        tx.close if tx
      end

      def touch(*) #:nodoc:
        run_callbacks(:touch) { super }
      end

      private

      def create_or_update #:nodoc:
        run_callbacks(:save) { super }
      end

      def create_model #:nodoc:
        Neo4j::Transaction.run do
          run_callbacks(:create) { super }
        end
      end

      def update_model(*) #:nodoc:
        Neo4j::Transaction.run do
          run_callbacks(:update) { super }
        end
      end
    end
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
neo4j-6.0.0.alpha.8 lib/neo4j/shared/callbacks.rb
neo4j-6.0.0.alpha.7 lib/neo4j/shared/callbacks.rb
neo4j-5.2.11 lib/neo4j/shared/callbacks.rb
neo4j-6.0.0.alpha.5 lib/neo4j/shared/callbacks.rb
neo4j-6.0.0.alpha.4 lib/neo4j/shared/callbacks.rb
neo4j-5.2.10 lib/neo4j/shared/callbacks.rb
neo4j-6.0.0.alpha.3 lib/neo4j/shared/callbacks.rb
neo4j-6.0.0.alpha.2 lib/neo4j/shared/callbacks.rb
neo4j-6.0.0.alpha.1 lib/neo4j/shared/callbacks.rb
neo4j-5.2.9 lib/neo4j/shared/callbacks.rb
neo4j-5.2.8 lib/neo4j/shared/callbacks.rb
neo4j-5.2.7 lib/neo4j/shared/callbacks.rb
neo4j-5.2.6 lib/neo4j/shared/callbacks.rb
neo4j-5.2.5 lib/neo4j/shared/callbacks.rb
neo4j-5.2.3 lib/neo4j/shared/callbacks.rb
neo4j-5.2.2 lib/neo4j/shared/callbacks.rb
neo4j-5.2.1 lib/neo4j/shared/callbacks.rb
neo4j-5.2.0 lib/neo4j/shared/callbacks.rb
neo4j-5.1.5 lib/neo4j/shared/callbacks.rb
neo4j-5.1.4 lib/neo4j/shared/callbacks.rb