Class: RR::ProxyCursor

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

Overview

Provides shared functionality for ProxyRowCursor and ProxyBlockCursor

Direct Known Subclasses

ProxyBlockCursor, ProxyRowCursor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, table) ⇒ ProxyCursor

Shared initializations

* connection: the current proxy connection
* table: table_name


24
25
26
27
28
# File 'lib/rubyrep/proxy_cursor.rb', line 24

def initialize(connection, table)
  self.connection = connection
  self.table = table
  self.primary_key_names = connection.primary_key_names table
end

Instance Attribute Details

#connectionObject

The current ProxyConnection.



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

def connection
  @connection
end

#cursorObject

The current cursor.



19
20
21
# File 'lib/rubyrep/proxy_cursor.rb', line 19

def cursor
  @cursor
end

#primary_key_namesObject

Array of primary key names for current table.



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

def primary_key_names
  @primary_key_names
end

#tableObject

The name of the current table.



13
14
15
# File 'lib/rubyrep/proxy_cursor.rb', line 13

def table
  @table
end

Instance Method Details

#destroyObject

Releases all ressources



39
40
41
42
# File 'lib/rubyrep/proxy_cursor.rb', line 39

def destroy
  self.cursor.clear if self.cursor
  self.cursor = nil
end

#prepare_fetch(options = {}) ⇒ Object

Initiate a query for the specified row range. options: An option hash that is used to construct the SQL query. See ProxyCursor#construct_query for details.



32
33
34
35
36
# File 'lib/rubyrep/proxy_cursor.rb', line 32

def prepare_fetch(options = {})
  self.cursor = connection.select_cursor(
    options.merge(:table => table, :type_cast => true)
  )
end