Class | SQLite3::Database::FunctionProxy |
In: |
lib/sqlite3/database.rb
|
Parent: | Object |
A helper class for dealing with custom functions (see create_function, create_aggregate, and create_aggregate_handler). It encapsulates the opaque function object that represents the current invocation. It also provides more convenient access to the API functions that operate on the function object.
This class will almost always be instantiated indirectly, by working with the create methods mentioned above.
Create a new FunctionProxy that encapsulates the given func object. If context is non-nil, the functions context will be set to that. If it is non-nil, it must quack like a Hash. If it is nil, then none of the context functions will be available.
# File lib/sqlite3/database.rb, line 672 672: def initialize( driver, func, context=nil ) 673: @driver = driver 674: @func = func 675: @context = context 676: end
Returns the value with the given key from the context. This is only available to aggregate functions.
# File lib/sqlite3/database.rb, line 705 705: def []( key ) 706: ensure_aggregate! 707: @context[ key ] 708: end
Sets the value with the given key in the context. This is only available to aggregate functions.
# File lib/sqlite3/database.rb, line 712 712: def []=( key, value ) 713: ensure_aggregate! 714: @context[ key ] = value 715: end
(Only available to aggregate functions.) Returns the number of rows that the aggregate has processed so far. This will include the current row, and so will always return at least 1.
# File lib/sqlite3/database.rb, line 698 698: def count 699: ensure_aggregate! 700: @driver.aggregate_count( @func ) 701: end
Calls set_result to set the result of this function.
# File lib/sqlite3/database.rb, line 679 679: def result=( result ) 680: set_result( result ) 681: end
Set the result of the function to the given error message. The function will then return that error.
# File lib/sqlite3/database.rb, line 691 691: def set_error( error ) 692: @driver.result_error( @func, error.to_s, -1 ) 693: end