Sha256: 5e5723ffa30621ec95377715369dabd02dbd5905739a180a3ee6aa8381a761ad

Contents?: true

Size: 513 Bytes

Versions: 2

Compression:

Stored size: 513 Bytes

Contents

# TODO: Needed?
module Neo4j
  module Core
    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 = args.last.is_a?(Neo4j::Session) ? args.pop : Neo4j::Session.current!

            Neo4j::Transaction.run(session.auto_commit?) { send(tx_method, *args, &block) }
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
neo4j-core-9.0.0 lib/neo4j/core/helpers.rb
neo4j-core-9.0.0.alpha.1 lib/neo4j/core/helpers.rb