Class: DataObjects::Transaction
- Defined in:
- lib/gems/data_objects-0.9.10.1/lib/data_objects/transaction.rb
Constant Summary collapse
- HOST =
"#{Socket::gethostbyname(Socket::gethostname)[0]}" rescue "localhost"
- @@counter =
0
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(uri) ⇒ Transaction
constructor
Creates a Transaction bound to the given connection.
Constructor Details
#initialize(uri) ⇒ Transaction
Creates a Transaction bound to the given connection
Parameters
- conn<DataObjects::Connection>
-
The Connection to bind the new Transaction to
25 26 27 28 |
# File 'lib/gems/data_objects-0.9.10.1/lib/data_objects/transaction.rb', line 25 def initialize(uri) @connection = DataObjects::Connection.new(uri) @id = Digest::SHA256.hexdigest("#{HOST}:#{$$}:#{Time.now.to_f}:#{@@counter += 1}") end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
11 12 13 |
# File 'lib/gems/data_objects-0.9.10.1/lib/data_objects/transaction.rb', line 11 def connection @connection end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/gems/data_objects-0.9.10.1/lib/data_objects/transaction.rb', line 12 def id @id end |
Class Method Details
.create_for_uri(uri) ⇒ Object
14 15 16 17 |
# File 'lib/gems/data_objects-0.9.10.1/lib/data_objects/transaction.rb', line 14 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 |
Instance Method Details
#close ⇒ Object
30 31 32 |
# File 'lib/gems/data_objects-0.9.10.1/lib/data_objects/transaction.rb', line 30 def close @connection.close end |