MooseX::Declare::Syntax::EmptyBlockIfMissing - Handle missing blocks after keywords


MooseX-Declare documentation Contained in the MooseX-Declare distribution.

Index


Code Index:

NAME

Top

MooseX::Declare::Syntax::EmptyBlockIfMissing - Handle missing blocks after keywords

DESCRIPTION

Top

The MooseX::Declare::Syntax::NamespaceHandling role will require that the consumer handles the case of non-existant blocks. This role will inject an empty block with only the generated code parts in it.

METHODS

Top

handle_missing_block

  Object->handle_missing_block (Object $context, Str $body, %args)

This will inject the generated code surrounded by { ... } into the code where the keyword was called.

SEE ALSO

Top

AUTHORS

Top

COPYRIGHT AND LICENSE

Top


MooseX-Declare documentation Contained in the MooseX-Declare distribution.

package MooseX::Declare::Syntax::EmptyBlockIfMissing;
BEGIN {
  $MooseX::Declare::Syntax::EmptyBlockIfMissing::AUTHORITY = 'cpan:FLORA';
}
BEGIN {
  $MooseX::Declare::Syntax::EmptyBlockIfMissing::VERSION = '0.34';
}
# ABSTRACT: Handle missing blocks after keywords

use Moose::Role;

use namespace::clean -except => 'meta';


sub handle_missing_block {
    my ($self, $ctx, $inject, %args) = @_;

    # default to block with nothing more than the default contents
    $ctx->inject_code_parts_here("{ $inject }");
}


1;

__END__