Class: UpAndAtThem::Commit

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

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Commit

Returns a new instance of Commit.

Raises:

  • (LocalJumpError)


5
6
7
8
# File 'lib/up_and_at_them.rb', line 5

def initialize(&block)
  raise LocalJumpError unless block_given?
  @block = block
end

Instance Method Details

#callObject



14
15
16
# File 'lib/up_and_at_them.rb', line 14

def call
  @block.call
end

#on_rollback(&block) ⇒ Object

Raises:

  • (LocalJumpError)


9
10
11
12
13
# File 'lib/up_and_at_them.rb', line 9

def on_rollback(&block)
  raise LocalJumpError unless block_given?
  @rollback = block
  self
end

#rollbackObject



17
18
19
# File 'lib/up_and_at_them.rb', line 17

def rollback
  @rollback.call if @rollback
end