Sha256: 47dcb9d1cec696a9492b9d4545841c1c12403072acbc0465255bee26a5c2862e

Contents?: true

Size: 607 Bytes

Versions: 23

Compression:

Stored size: 607 Bytes

Contents

module Neo4j
  module Core
    module ArgumentHelper
      def self.session(args)
        args.last.is_a?(Neo4j::Session) ? args.pop : Neo4j::Session.current!
      end
    end

    module TxMethods
      def tx_methods(*methods)
        methods.each do |method|
          tx_method = "#{method}_in_tx"
          send(:alias_method, tx_method, method)
          send(:define_method, method) do |*args, &block|
            session = ArgumentHelper.session(args)
            Neo4j::Transaction.run(session.auto_commit?) { send(tx_method, *args, &block) }
          end
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
neo4j-core-5.0.10 lib/neo4j-core/helpers.rb
neo4j-core-5.0.9 lib/neo4j-core/helpers.rb
neo4j-core-5.0.8 lib/neo4j-core/helpers.rb
neo4j-core-5.0.7 lib/neo4j-core/helpers.rb
neo4j-core-5.0.6 lib/neo4j-core/helpers.rb
neo4j-core-5.0.5 lib/neo4j-core/helpers.rb
neo4j-core-5.0.4 lib/neo4j-core/helpers.rb
neo4j-core-5.0.3 lib/neo4j-core/helpers.rb
neo4j-core-5.0.2 lib/neo4j-core/helpers.rb
neo4j-core-5.0.1 lib/neo4j-core/helpers.rb
neo4j-core-5.0.0 lib/neo4j-core/helpers.rb
neo4j-core-5.0.0.rc.4 lib/neo4j-core/helpers.rb
neo4j-core-5.0.0.rc.3 lib/neo4j-core/helpers.rb
neo4j-core-5.0.0.rc.2 lib/neo4j-core/helpers.rb
neo4j-core-5.0.0.rc.1 lib/neo4j-core/helpers.rb
neo4j-core-4.0.7 lib/neo4j-core/helpers.rb
neo4j-core-4.0.6 lib/neo4j-core/helpers.rb
neo4j-core-4.0.5 lib/neo4j-core/helpers.rb
neo4j-core-4.0.4 lib/neo4j-core/helpers.rb
neo4j-core-4.0.3 lib/neo4j-core/helpers.rb