Bot::ChatBots::Role::Sender - Bot::ChatBots Role for Senders
package Something; use Moo; with 'Bot::ChatBots::Role::Processor'; sub process { my ($self, $record) = @_; $record->{foo} = 'bar'; return $record; } 1; # later that night... my $something = Something->new; my $sub_ref = $something->processor; my $output_record = $sub_ref->($input_record);
This is a sender role for bots.
If process behaves correctly, "processor" is Data::Tubes-compliant.
This is what you should provide and probably override in the general case:
"process" is mandatory and it is where you actually process records. You are strongly suggested to use the Data::Tubes interface (it's simple).
It should be safe to override the following methods in your classes composing this role.
my $sub_ref = $obj->processor;
Return a sub wrapping "process", like this:
sub processor { my $self = shift; return sub { return $self->process(@_); }
This class defines a Moo::Role, so it's not a standalone thing by itself. The following methods are required to exist in the class that composes this role.
my $output = $obj->process($input);
Do actual processing of a record. You are strongly suggested to adhere to the Data::Tubes interface.
Bot::ChatBots.
Flavio Poletti <polettix@cpan.org>
Copyright (C) 2016 by Flavio Poletti <polettix@cpan.org>
This module is free software. You can redistribute it and/or modify it under the terms of the Artistic License 2.0.
This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.
To install Bot::ChatBots, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bot::ChatBots
CPAN shell
perl -MCPAN -e shell install Bot::ChatBots
For more information on module installation, please visit the detailed CPAN module installation guide.