Class: DataObjects::Transaction

### Home Classes Methods

### In Files

- lib/data_objects/transaction.rb

### Parent

Object

### Methods

- ::create_for_uri
- ::new
- #begin
- #begin_prepared
- #close
- #commit
- #commit_prepared
- #prepare
- #rollback
- #rollback_prepared
- #run

### Class/Module Index

Quicksearch

- DataObjects
- DataObjects::Command
- DataObjects::Connection
- DataObjects::ConnectionError
- DataObjects::DataError
- DataObjects::Error
- DataObjects::Extension
- DataObjects::IntegrityError
- DataObjects::Logger
- DataObjects::Logging
- DataObjects::Pooling
- DataObjects::Pooling::InvalidResourceError
- DataObjects::Pooling::Pool
- DataObjects::Quoting
- DataObjects::Reader
- DataObjects::Result
- DataObjects::SQLError
- DataObjects::SavePoint
- DataObjects::Spec
- DataObjects::Spec::PendingHelpers
- DataObjects::SyntaxError
- DataObjects::Transaction
- DataObjects::TransactionError
- DataObjects::URI
- Extlib
- Extlib::ByteArray
- CustomTextType
- MyString
- Object
- SSLHelpers

No matching classes.

# DataObjects::Transaction

### Constants

HOST

  The local host name. Do not attempt to resolve in DNS to prevent potentially long delay

### Attributes

connection[R]

The connection object allocated for this transaction

id[R]

A unique ID for this transaction

### Public Class Methods

create_for_uri(uri) click to toggle source

Instantiate the Transaction subclass that's appropriate for this uri scheme

    # File lib/data_objects/transaction.rb, line 19
    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

new(uri, connection = nil) click to toggle source

Creates a Transaction bound to a connection for the given DataObjects::URI

    # File lib/data_objects/transaction.rb, line 27
    def initialize(uri, connection = nil)
      @connection = connection || DataObjects::Connection.new(uri)
      # PostgreSQL can't handle the full 64 bytes.  This should be enough for everyone.
      @id = Digest::SHA256.hexdigest("#{HOST}:#{$$}:#{Time.now.to_f}:#{@@counter += 1}")[0..-2]
    end

### Public Instance Methods

begin() click to toggle source

    # File lib/data_objects/transaction.rb, line 38
    def begin
      run "BEGIN"
    end

begin_prepared() click to toggle source

    # File lib/data_objects/transaction.rb, line 51
    def begin_prepared; not_implemented; end

close() click to toggle source

Close the connection for this Transaction

    # File lib/data_objects/transaction.rb, line 34
    def close
      @connection.close
    end

commit() click to toggle source

    # File lib/data_objects/transaction.rb, line 42
    def commit
      run "COMMIT"
    end

commit_prepared() click to toggle source

    # File lib/data_objects/transaction.rb, line 52
    def commit_prepared; not_implemented; end

prepare() click to toggle source

    # File lib/data_objects/transaction.rb, line 50
    def prepare; not_implemented; end

rollback() click to toggle source

    # File lib/data_objects/transaction.rb, line 46
    def rollback
      run "ROLLBACK"
    end

rollback_prepared() click to toggle source

    # File lib/data_objects/transaction.rb, line 53
    def rollback_prepared; not_implemented; end

### Protected Instance Methods

run(cmd) click to toggle source

    # File lib/data_objects/transaction.rb, line 57
    def run(cmd)
      connection.create_command(cmd).execute_non_query
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.