Module: BFS::Writer::Mixin

Included in:
Bucket::InMem::Writer, BFS::Writer
Defined in:
lib/bfs/helpers.rb

Instance Method Summary collapse

Instance Method Details

#commitObject



18
19
20
21
22
23
24
25
26
# File 'lib/bfs/helpers.rb', line 18

def commit
  close
  return false if @on_commit.nil?

  @on_commit.call(commit_ref)
  true
ensure
  discard
end

#discardObject



28
29
30
31
# File 'lib/bfs/helpers.rb', line 28

def discard
  @on_commit = nil
  close!
end

#performObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/bfs/helpers.rb', line 7

def perform
  return self unless block_given?

  begin
    yield self
    commit
  ensure
    discard
  end
end