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.

Methods
Public Class methods
new( driver, func, context=nil )

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 671
671:       def initialize( driver, func, context=nil )
672:         @driver = driver
673:         @func = func
674:         @context = context
675:       end
Public Instance methods
[]( key )

Returns the value with the given key from the context. This is only available to aggregate functions.

     # File lib/sqlite3/database.rb, line 704
704:       def []( key )
705:         ensure_aggregate!
706:         @context[ key ]
707:       end
[]=( key, value )

Sets the value with the given key in the context. This is only available to aggregate functions.

     # File lib/sqlite3/database.rb, line 711
711:       def []=( key, value )
712:         ensure_aggregate!
713:         @context[ key ] = value
714:       end
count()

(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 697
697:       def count
698:         ensure_aggregate!
699:         @driver.aggregate_count( @func )
700:       end
result=( result )

Calls set_result to set the result of this function.

     # File lib/sqlite3/database.rb, line 678
678:       def result=( result )
679:         set_result( result )
680:       end
set_error( error )

Set the result of the function to the given error message. The function will then return that error.

     # File lib/sqlite3/database.rb, line 690
690:       def set_error( error )
691:         @driver.result_error( @func, error.to_s, -1 )
692:       end
set_result( result, utf16=false )

Set the result of the function to the given value. The function will then return this value.

     # File lib/sqlite3/database.rb, line 684
684:       def set_result( result, utf16=false )
685:         @driver.result_text( @func, result, utf16 )
686:       end

[Validate]