Sha256: e8241906d7b9845cc4fc7feb0ab8836c2a5ab882ad8d65cc5c7380b69e0b9192

Contents?: true

Size: 565 Bytes

Versions: 13

Compression:

Stored size: 565 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

13 entries across 13 versions & 1 rubygems

Version Path
neo4j-core-3.0.0.alpha.16 lib/neo4j-core/helpers.rb
neo4j-core-3.0.0.alpha.15 lib/neo4j-core/helpers.rb
neo4j-core-3.0.0.alpha.14 lib/neo4j-core/helpers.rb
neo4j-core-3.0.0.alpha.13 lib/neo4j-core/helpers.rb
neo4j-core-3.0.0.alpha.12 lib/neo4j-core/helpers.rb
neo4j-core-3.0.0.alpha.11 lib/neo4j-core/helpers.rb
neo4j-core-3.0.0.alpha.10 lib/neo4j-core/helpers.rb
neo4j-core-3.0.0.alpha.9 lib/neo4j-core/helpers.rb
neo4j-core-3.0.0.alpha.8 lib/neo4j-core/helpers.rb
neo4j-core-3.0.0.alpha.7 lib/neo4j-core/helpers.rb
neo4j-core-3.0.0.alpha.6 lib/neo4j-core/helpers.rb
neo4j-core-3.0.0.alpha.5 lib/neo4j-core/helpers.rb
neo4j-core-3.0.0.alpha.4 lib/neo4j-core/helpers.rb