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( 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/sqlite/database.rb, line 628
628:       def initialize( func, context=nil )
629:         @func = func
630:         @context = context
631:       end
Public Instance methods
[]( key )

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

     # File lib/sqlite/database.rb, line 655
655:       def []( key )
656:         ensure_aggregate!
657:         @context[ key ]
658:       end
[]=( key, value )

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

     # File lib/sqlite/database.rb, line 662
662:       def []=( key, value )
663:         ensure_aggregate!
664:         @context[ key ] = value
665:       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/sqlite/database.rb, line 648
648:       def count
649:         ensure_aggregate!
650:         SQLite::API.aggregate_count( @func )
651:       end
set_error( error )

Set the result of the function to the given error message, which must be a string. The function will then return that error.

     # File lib/sqlite/database.rb, line 641
641:       def set_error( error )
642:         SQLite::API.set_result_error( @func, error )
643:       end
set_result( result )

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

     # File lib/sqlite/database.rb, line 635
635:       def set_result( result )
636:         SQLite::API.set_result( @func, result )
637:       end

[Validate]