Sha256: 2b1437830550ebead950012cc516ac80ba9ef335ea022c1a4e27af04d1129a80

Contents?: true

Size: 749 Bytes

Versions: 4

Compression:

Stored size: 749 Bytes

Contents

module Neo4j
  module Rails

    # This method is typically used in an Rails ActionController as a filter method.
    # It will guarantee that an transaction is create before your action is called,
    # and that the transaction is finished after your action is called.
    #
    # Example:
    #  class MyController < ActionController::Base
    #      around_filter Neo4j::Rails::Transaction, :only => [:edit, :delete]
    #      ...
    #  end
    class Transaction
      def self.filter(*)
        begin
          tx = Neo4j::Transaction.new
          yield
          tx.success
        rescue Exception
          tx.failure unless tx.nil?
          raise
        ensure
          tx.finish unless tx.nil?
        end
      end
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
neo4j-1.0.0.beta.4 lib/neo4j/rails/transaction.rb
neo4j-1.0.0.beta.3 lib/neo4j/rails/transaction.rb
neo4j-1.0.0.beta.2 lib/neo4j/rails/transaction.rb
neo4j-1.0.0.beta.1 lib/neo4j/rails/transaction.rb