Bot-Backbone
view release on metacpan or search on metacpan
lib/Bot/Backbone/DispatchSugar.pm view on Meta::CPAN
$dispatcher->add_predicate_or_return(
Bot::Backbone::Dispatcher::Predicate::Volume->new(
volume => 'whisper',
next_predicate => $predicate,
)
);
}
our $WITH_ARGS;
sub given_parameters(&$) {
my ($meta, $arg_code, $predicate) = @_;
my $dispatcher = $meta->building_dispatcher;
my @args;
{
local $WITH_ARGS = \@args;
$arg_code->();
}
$dispatcher->add_predicate_or_return(
lib/Bot/Backbone/DispatchSugar.pm view on Meta::CPAN
next_predicate => $predicate,
)
);
}
sub parameter($@) {
my ($name, %config) = @_;
push @$WITH_ARGS, [ $name, \%config ];
}
sub as(&) {
my $code = shift;
return $code;
}
sub _respond {
my ($meta, $code, $dispatcher_type) = @_;
my $dispatcher = $meta->building_dispatcher;
$dispatcher_type //= $meta;
$dispatcher->add_predicate_or_return(
Bot::Backbone::Dispatcher::Predicate::Respond->new(
dispatcher_type => $dispatcher_type,
the_code => $code,
)
);
}
sub respond(&) {
my ($meta, $code, $dispatcher_type) = @_;
_respond($meta, $code, $dispatcher_type);
}
sub _run_this {
my ($meta, $code, $dispatcher_type) = @_;
my $dispatcher = $meta->building_dispatcher;
$dispatcher_type //= $meta;
$dispatcher->add_predicate_or_return(
Bot::Backbone::Dispatcher::Predicate::Run->new(
dispatcher_type => $dispatcher_type,
the_code => $code,
)
);
}
sub run_this(&) {
my ($meta, $code, $dispatcher_type) = @_;
_run_this($meta, $code, $dispatcher_type);
}
sub _by_method {
my ($meta, $name) = @_;
Carp::croak("no such method as $name found on ", $meta->name)
unless defined $meta->find_method_by_name($name);
( run in 1.746 second using v1.01-cache-2.11-cpan-49f99fa48dc )