Dancer2
view release on metacpan or search on metacpan
lib/Dancer2/Core/DSL.pm view on Meta::CPAN
# ABSTRACT: Dancer2's Domain Specific Language (DSL)
package Dancer2::Core::DSL;
$Dancer2::Core::DSL::VERSION = '2.1.0';
use Moo;
use Carp;
use Path::Tiny ();
use Module::Runtime 'require_module';
use Ref::Util qw< is_arrayref is_hashref >;
use Dancer2::Core::Hook;
use Dancer2::Core::Response::Delayed;
with 'Dancer2::Core::Role::DSL';
sub hook_aliases { +{} }
sub supported_hooks { () }
sub _add_postponed_plugin_hooks {
my ( $self, $postponed_hooks) = @_;
$postponed_hooks = $postponed_hooks->{'plugin'};
return unless defined $postponed_hooks;
for my $plugin ( keys %{$postponed_hooks} ) {
for my $name ( keys %{$postponed_hooks->{$plugin} } ) {
my $hook = $postponed_hooks->{$plugin}{$name}{hook};
my $caller = $postponed_hooks->{$plugin}{$name}{caller};
$self->has_hook($name)
or croak "plugin $plugin does not support the hook `$name'. ("
. join( ", ", @{$caller} ) . ")";
$self->add_hook($hook);
}
}
}
sub dsl_keywords {
# the flag means : 1 = is global, 0 = is not global. global means can be
# called from anywhere. not global means must be called from within a route
# handler
{ any => { is_global => 1 },
app => { is_global => 1 },
captures => { is_global => 0 },
config => { is_global => 1 },
content => { is_global => 0 },
content_type => { is_global => 0 },
context => { is_global => 0 },
cookie => { is_global => 0 },
cookies => { is_global => 0 },
dance => { is_global => 1 },
dancer_app => { is_global => 1 },
dancer_version => { is_global => 1 },
dancer_major_version => { is_global => 1 },
debug => { is_global => 1 },
decode_json => { is_global => 1 },
del => { is_global => 1 },
delayed => {
is_global => 0, prototype => '&@',
},
dirname => { is_global => 1 },
done => { is_global => 0 },
dsl => { is_global => 1 },
encode_json => { is_global => 1 },
engine => { is_global => 1 },
error => { is_global => 1 },
false => { is_global => 1 },
flush => { is_global => 0 },
( run in 0.726 second using v1.01-cache-2.11-cpan-39bf76dae61 )