U:RDoc::AnyMethod[iI"create_aggregate_handler:EFI"/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"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"