PerlDancer/Dancer2 — pull request #819 by JRaspass (2014-12-28 22:40:52+00:00)
Title: Simplify D2::Core::Role::DSL::export_symbols_to

When importing the DSL keywords into the caller they are currently wrapped in
subs that close over $self like so:

*caller::foo = sub { $self->foo(@_) }

This allows simple calling conventions for the caller. If the keyword has
restrictions on where is can be called from (is_global=0) then this sub is
additionally wrapped like so:

my $code = sub { $self->foo(@_) };

*caller::foo = sub {
croak 'Not from here buddy' unless $self->app->has_request;

$code->(@_);
};

This is wasteful as it creates another layer of indirection. This commit changes
how those DSL keywords are imported like so:

*caller::foo = sub {
croak 'Not from here buddy' unless $self->app->has_request;

$self->foo(@_);
};

One point of note is that export_symbols_to no longer returns a list of what it
has imported, the two and only calls to this don't seem to make use of this so I
can't see it being a huge issue but it could be made to work if needed.