Class: RR::NoisyCursor

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

Overview

Wraps an existing cursor. Purpose: send regular updates to the installed TaskSweeper

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cursor, sweeper) ⇒ NoisyCursor

Create a new NoisyCursor.

  • cursor: the original cursor

  • sweeper: the target TaskSweeper



15
16
17
18
# File 'lib/rubyrep/noisy_connection.rb', line 15

def initialize(cursor, sweeper)
  self.org_cursor = cursor
  self.sweeper = sweeper
end

Instance Attribute Details

#org_cursorObject

The original cusor



7
8
9
# File 'lib/rubyrep/noisy_connection.rb', line 7

def org_cursor
  @org_cursor
end

#sweeperObject

The installed task sweeper



10
11
12
# File 'lib/rubyrep/noisy_connection.rb', line 10

def sweeper
  @sweeper
end

Instance Method Details

#clearObject



22
# File 'lib/rubyrep/noisy_connection.rb', line 22

def clear; org_cursor.clear end

#next?Boolean

Delegate the uninteresting methods to the original cursor

Returns:

  • (Boolean)


21
# File 'lib/rubyrep/noisy_connection.rb', line 21

def next?; org_cursor.next? end

#next_rowObject

Returns the row as a column => value hash and moves the cursor to the next row.



25
26
27
28
29
30
# File 'lib/rubyrep/noisy_connection.rb', line 25

def next_row
  sweeper.ping
  row = org_cursor.next_row
  sweeper.ping
  row
end