class Amalgalite::SQLite3::Database::Function
A wrapper around a proc for use as an SQLite Ddatabase fuction
f = Function.new( 'md5', lambda { |x| Digest::MD5.hexdigest( x.to_s ) } )
Attributes
name[R]
the name of the function, and how it will be called in SQL
Public Class Methods
new( name, _proc )
click to toggle source
Initialize with the name and the Proc
# File lib/amalgalite/sqlite3/database/function.rb, line 22 def initialize( name, _proc ) @name = name @function = _proc end
signature( name, arity )
click to toggle source
The unique signature of this function. This is used to determin if the function is already registered or not
# File lib/amalgalite/sqlite3/database/function.rb, line 16 def self.signature( name, arity ) "#{name}/#{arity}" end
Public Instance Methods
arity()
click to toggle source
The arity of SQL function, -1 means it is takes a variable number of arguments.
# File lib/amalgalite/sqlite3/database/function.rb, line 37 def arity @function.arity end
call( *args )
click to toggle source
Invoke the proc
# File lib/amalgalite/sqlite3/database/function.rb, line 43 def call( *args ) @function.call( *args ) end
signature()
click to toggle source
The unique signature of this function
# File lib/amalgalite/sqlite3/database/function.rb, line 29 def signature @signature ||= Function.signature( name, arity ) end
Also aliased as: to_s