Sha256: f9c106f254f2f2c6b94c87b190c204ada5bf818fe249f41b4dc15dba13e560b7

Contents?: true

Size: 566 Bytes

Versions: 17

Compression:

Stored size: 566 Bytes

Contents

module Neo4j::Core

  module ArgumentHelper

    def self.session(args)
      args.last.kind_of?(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

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
neo4j-core-3.1.1 lib/neo4j-core/helpers.rb
neo4j-core-3.1.0 lib/neo4j-core/helpers.rb
neo4j-core-3.0.8 lib/neo4j-core/helpers.rb
neo4j-core-3.0.7 lib/neo4j-core/helpers.rb
neo4j-core-3.0.6 lib/neo4j-core/helpers.rb
neo4j-core-3.0.5 lib/neo4j-core/helpers.rb
neo4j-core-3.0.4 lib/neo4j-core/helpers.rb
neo4j-core-3.0.3 lib/neo4j-core/helpers.rb
neo4j-core-3.0.2 lib/neo4j-core/helpers.rb
neo4j-core-3.0.1 lib/neo4j-core/helpers.rb
neo4j-core-3.0.0 lib/neo4j-core/helpers.rb
neo4j-core-3.0.0.rc.5 lib/neo4j-core/helpers.rb
neo4j-core-3.0.0.rc.4 lib/neo4j-core/helpers.rb
neo4j-core-3.0.0.rc.1 lib/neo4j-core/helpers.rb
neo4j-core-3.0.0.alpha.19 lib/neo4j-core/helpers.rb
neo4j-core-3.0.0.alpha.18 lib/neo4j-core/helpers.rb
neo4j-core-3.0.0.alpha.17 lib/neo4j-core/helpers.rb