Class: Vangrail::PreparedTransaction

Inherits:
Object
  • Object
show all
Defined in:
lib/vangrail/tools.rb

Overview

Opaque prepared state for one transactional Call.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(call, payload) ⇒ PreparedTransaction

Returns a new instance of PreparedTransaction.



12
13
14
15
16
17
18
19
# File 'lib/vangrail/tools.rb', line 12

def initialize(call, payload)
  @id = SecureRandom.uuid.freeze
  @call_id = call.id
  @fingerprint = call.fingerprint.freeze
  @tool = call.tool
  @payload = payload
  @state = :prepared
end

Instance Attribute Details

#call_id ⇒ Object (readonly)

Returns the value of attribute call_id.



10
11
12
# File 'lib/vangrail/tools.rb', line 10

def call_id
  @call_id
end

#fingerprint ⇒ Object (readonly)

Returns the value of attribute fingerprint.



10
11
12
# File 'lib/vangrail/tools.rb', line 10

def fingerprint
  @fingerprint
end

#id ⇒ Object (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/vangrail/tools.rb', line 10

def id
  @id
end

#payload ⇒ Object (readonly)

Returns the value of attribute payload.



10
11
12
# File 'lib/vangrail/tools.rb', line 10

def payload
  @payload
end

#state ⇒ Object (readonly)

Returns the value of attribute state.



10
11
12
# File 'lib/vangrail/tools.rb', line 10

def state
  @state
end

#tool ⇒ Object (readonly)

Returns the value of attribute tool.



10
11
12
# File 'lib/vangrail/tools.rb', line 10

def tool
  @tool
end

Instance Method Details

#commit! ⇒ Object



25
26
27
# File 'lib/vangrail/tools.rb', line 25

def commit!
  @state = :committed
end

#prepared? ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/vangrail/tools.rb', line 21

def prepared?
  state == :prepared
end

#rollback! ⇒ Object



29
30
31
# File 'lib/vangrail/tools.rb', line 29

def rollback!
  @state = :rolled_back
end