HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/local/rvm/gems/default/doc/sqlite3-1.4.2/ri/SQLite3/Database/create_aggregate_handler-i.ri
U:RDoc::AnyMethod[iI"create_aggregate_handler:ETI"/SQLite3::Database#create_aggregate_handler;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph;	[
I"EThis is another approach to creating an aggregate function (see ;TI"D#create_aggregate). Instead of explicitly specifying the name, ;TI">callbacks, arity, and type, you specify a factory object ;TI"K(the "handler") that knows how to obtain all of that information. The ;TI"6handler should respond to the following messages:;To:RDoc::Markup::BlankLineo:RDoc::Markup::List:
@type:	NOTE:@items[o:RDoc::Markup::ListItem:@label[I"+arity+;T;	[o;
;	[I"Ecorresponds to the +arity+ parameter of #create_aggregate. This ;TI"Emessage is optional, and if the handler does not respond to it, ;TI"+the function will have an arity of -1.;To;;[I"+name+;T;	[o;
;	[I"Dthis is the name of the function. The handler _must_ implement ;TI"this message.;To;;[I"
+new+;T;	[o;
;	[I"Ethis must be implemented by the handler. It should return a new ;TI"Finstance of the object that will handle a specific invocation of ;TI"the function.;T@o;
;	[I"OThe handler instance (the object returned by the +new+ message, described ;TI"4above), must respond to the following messages:;T@o;;
;;[o;;[I"+step+;T;	[o;
;	[I"Athis is the method that will be called for each step of the ;TI"Caggregate function's evaluation. It should implement the same ;TI"<signature as the +step+ callback for #create_aggregate.;To;;[I"+finalize+;T;	[o;
;	[	I"<this is the method that will be called to finalize the ;TI">aggregate function's evaluation. It should implement the ;TI"3same signature as the +finalize+ callback for ;TI"#create_aggregate.;T@o;
;	[I"
Example:;T@o:RDoc::Markup::Verbatim;	[I"#class LengthsAggregateHandler
;TI"  def self.arity; 1; end
;TI"%  def self.name; 'lengths'; end
;TI"
;TI"  def initialize
;TI"    @total = 0
;TI"  end
;TI"
;TI"  def step( ctx, name )
;TI".    @total += ( name ? name.length : 0 )
;TI"  end
;TI"
;TI"  def finalize( ctx )
;TI"    ctx.result = @total
;TI"  end
;TI"	end
;TI"
;TI"<db.create_aggregate_handler( LengthsAggregateHandler )
;TI"=puts db.get_first_value( "select lengths(name) from A" );T:@format0:
@fileI"lib/sqlite3/database.rb;T:0@omit_headings_from_table_of_contents_below000[I"( handler );T@`FI"
Database;TcRDoc::NormalClass00