# File lib/sqlite/database.rb, line 350 def create_function( name, arity, type=nil, &block ) # :yields: func, *args case type when :numeric type = SQLite::API::NUMERIC when :text type = SQLite::API::TEXT when :args type = SQLite::API::ARGS end callback = proc do |func,*args| begin block.call( FunctionProxy.new( func ), *args ) rescue Exception => e SQLite::API.set_result_error( func, "#{e.message} (#{e.class})" ) end end SQLite::API.create_function( @handle, name, arity, callback ) SQLite::API.function_type( @handle, name, type ) if type self end