Creates a function with the same signature as SQLite::Database
# File vendor/plugins/ubiquo_core/lib/ubiquo/adapters/sqlite.rb, line 73
73: def create_function(name, arity, text_rep='default', &block)
74: generic_function = Class.new(org.sqlite.Function)
75: generic_function.class_eval do
76:
77: # All org.sqlite.Function subclasses must implement xFunc(),
78: # which is called when SQLite runs the custom function
79: define_method 'xFunc' do
80: # receiver is the first expected argument for the block
81: # receiver.result will be used by the block to store
82: block_args = [receiver = OpenStruct.new]
83:
84: # prepare all the other block arguments
85: args.times{|i| block_args << value_text(i)}
86:
87: # now call the given block and return the value using +result+
88: block.call(*block_args)
89: result(receiver.result)
90: end
91:
92: end
93:
94: org.sqlite.Function.create(self.connection, name, generic_function.new)
95: end
Disabled; run with $DEBUG to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.