The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Bot::ChatBots::Role::Sender - Bot::ChatBots Role for Senders

SYNOPSIS

   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);

DESCRIPTION

This is a sender role for bots.

If process behaves correctly, "processor" is Data::Tubes-compliant.

What Should You Provide/Override

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).

METHODS

It should be safe to override the following methods in your classes composing this role.

processor

   my $sub_ref = $obj->processor;

Return a sub wrapping "process", like this:

   sub processor {
      my $self = shift;
      return sub { return $self->process(@_);
   }

REQUIRED METHODS

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.

process

   my $output = $obj->process($input);

Do actual processing of a record. You are strongly suggested to adhere to the Data::Tubes interface.

SEE ALSO

Bot::ChatBots.

AUTHOR

Flavio Poletti <polettix@cpan.org>

COPYRIGHT AND LICENSE

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.