# activerecord-spanner-adapter - Class ActiveRecordSpannerAdapter::Transaction (v2.2.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.2.0 (latest)](https://docs.cloud.google.com/ruby/docs/reference/activerecord-spanner-adapter/latest/ActiveRecordSpannerAdapter-Transaction)
- [2.1.0](https://docs.cloud.google.com/ruby/docs/reference/activerecord-spanner-adapter/2.1.0/ActiveRecordSpannerAdapter-Transaction)
- [2.0.0](https://docs.cloud.google.com/ruby/docs/reference/activerecord-spanner-adapter/2.0.0/ActiveRecordSpannerAdapter-Transaction)
Reference documentation and code samples for the activerecord-spanner-adapter class ActiveRecordSpannerAdapter::Transaction.

## Inherits

- Object

## Methods

### #_transaction_isolation_level_to_grpc

    def _transaction_isolation_level_to_grpc(isolation)

### #active?

    def active?() -> Boolean

**Returns**

- (Boolean)

### #begin

    def begin()

Begins the transaction.


<br />

Read-only and PDML transactions are started by executing a BeginTransaction RPC.
Read/write transactions are not really started by this method, and instead a
transaction selector is prepared that will be included with the first statement
on the transaction.

### #buffer

    def buffer(mutation)

### #commit

    def commit()

### #force_begin_read_write

    def force_begin_read_write()

Forces a BeginTransaction RPC for a read/write transaction. This is used by a
connection if the first statement of a transaction failed.

### #grpc_transaction=

    def grpc_transaction=(grpc)

Sets the underlying gRPC transaction to use for this Transaction.
This is used for queries/DML statements that inlined the BeginTransaction option and returned
a transaction in the metadata.

### #initialize

    def initialize(connection, isolation) -> Transaction

**Returns**

- ([Transaction](https://docs.cloud.google.com/ruby/docs/reference/activerecord-spanner-adapter/latest/ActiveRecordSpannerAdapter-Transaction)) --- a new instance of Transaction

### #isolation

    def isolation()

### #mark_aborted

    def mark_aborted()

### #next_sequence_number

    def next_sequence_number()

### #rollback

    def rollback()

### #shoot_and_forget_rollback

    def shoot_and_forget_rollback()

### #state

    def state()

Returns the value of attribute state.

### #transaction_selector

    def transaction_selector()