Sha256: a31b676ad0d93d01a34d5cd5a362824456e0e0a9f348a8f0928865a175d527bd
Contents?: true
Size: 981 Bytes
Versions: 10
Compression:
Stored size: 981 Bytes
Contents
require 'digest' require 'digest/sha2' module DataObjects class Transaction HOST = "#{Socket::gethostbyname(Socket::gethostname)[0]}" rescue "localhost" @@counter = 0 attr_reader :connection attr_reader :id def self.create_for_uri(uri) uri = uri.is_a?(String) ? URI::parse(uri) : uri DataObjects.const_get(uri.scheme.capitalize)::Transaction.new(uri) end # # Creates a Transaction bound to the given connection # # ==== Parameters # conn<DataObjects::Connection>:: The Connection to bind the new Transaction to # def initialize(uri) @connection = DataObjects::Connection.new(uri) @id = Digest::SHA256.hexdigest("#{HOST}:#{$$}:#{Time.now.to_f}:#{@@counter += 1}") end def close @connection.close end [:begin, :commit, :rollback, :rollback_prepared, :prepare].each do |method_name| eval <<EOF def #{method_name} raise NotImplementedError end EOF end end end
Version data entries
10 entries across 10 versions & 2 rubygems