Class: DBI::Handle

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

Overview

Base class for all handles.

Direct Known Subclasses

DatabaseHandle, DriverHandle, StatementHandle

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handle, convert_types = true) ⇒ Handle

Returns a new instance of Handle.



14
15
16
17
18
# File 'lib/dbi/handles.rb', line 14

def initialize(handle, convert_types=true)
    @handle = handle
    @trace_mode = @trace_output = nil
    @convert_types = convert_types
end

Instance Attribute Details

#convert_typesObject

Returns the value of attribute convert_types.



12
13
14
# File 'lib/dbi/handles.rb', line 12

def convert_types
  @convert_types
end

#handleObject (readonly)

Returns the value of attribute handle.



11
12
13
# File 'lib/dbi/handles.rb', line 11

def handle
  @handle
end

#trace_modeObject (readonly)

Returns the value of attribute trace_mode.



10
11
12
# File 'lib/dbi/handles.rb', line 10

def trace_mode
  @trace_mode
end

#trace_outputObject (readonly)

Returns the value of attribute trace_output.



10
11
12
# File 'lib/dbi/handles.rb', line 10

def trace_output
  @trace_output
end

Instance Method Details

#func(function, *values) ⇒ Object

Leverage a driver-specific method. The method name will have “__” prepended to them before calling, and the DBD must define them as such for them to work.



33
34
35
36
37
38
39
40
41
# File 'lib/dbi/handles.rb', line 33

def func(function, *values)
    if @handle.respond_to?("__" + function.to_s) then
        @handle.send("__" + function.to_s, *values)  
    else
        raise InterfaceError, "Driver specific function <#{function}> not available."
    end
rescue ArgumentError
    raise InterfaceError, "Wrong # of arguments for driver specific function"
end

#trace(mode = nil, output = nil) ⇒ Object

Please seee DBI.trace.

Raises:



21
22
23
24
25
26
# File 'lib/dbi/handles.rb', line 21

def trace(mode=nil, output=nil)
    # FIXME trace
    raise InterfaceError, "the trace module has been removed until it actually works."
    @trace_mode   = mode   || @trace_mode   || DBI::DEFAULT_TRACE_MODE
    @trace_output = output || @trace_output || DBI::DEFAULT_TRACE_OUTPUT
end