SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG
DONATE


YUM REPOSITORY

 
 

MAN page from Fedora 28 perl-MooseX-Declare-0.43-7.fc28.noarch.rpm

MooseX::Declare::Syntax::NamespaceHandling

Section: User Contributed Perl Documentation (3pm)
Updated: 2015-08-16
Index 

NAME

MooseX::Declare::Syntax::NamespaceHandling - Handle namespaced blocks 

VERSION

version 0.43 

DESCRIPTION

Allows the implementation of namespaced blocks like therole andclass keyword handlers.

Namespaces are automatically nested. Meaning that, for example, a "class Bar"declaration inside another "class Foo" block gives the inner one actually thename "Foo::Bar". 

METHODS

 

parse

  Any Object->parse (Object $context)

This is the main handling routine for namespaces. It will remove the namespacename and its options. If the handler was invoked without a name, options ora following block, it is assumed that this is an instance of an autoquotedbareword like "class => "Foo"".

The return value of the "parse" method is also the value that is returnedto the user of the keyword. 

CONSUMES

*
MooseX::Declare::Syntax::KeywordHandling
*
MooseX::Declare::Syntax::InnerSyntaxHandling
 

REQUIRED METHODS

 

handle_missing_block

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

This must be implemented to decide what to do in case the statement isterminated rather than followed by a block. It will receive the contextobject, the produced code that needs to be injected, and all the argumentsthat were passed to the call to ``inject_code_parts'' in MooseX::Declare::Context.

The return value will be ignored. 

EXTENDABLE STUB METHODS

 

add_namespace_customizations

 

add_optional_customizations

  Object->add_namespace_customizations (Object $context, Str $package, HashRef $options)  Object->add_optional_customizations  (Object $context, Str $package, HashRef $options)

These will be called (in this order) by the ``parse'' method. They allow specific hooksto attach before/after/around the customizations for the namespace and the providedoptions that are not attached to the namespace directly.

While this distinction might seem superficial, we advise library developers facilitatingthis role to follow the precedent. This ensures that when another component needs totie between the namespace and any additional customizations everything will run in thecorrect order. An example of this separation would be

  class Foo is mutable ...

being an option of the namespace generation, while

  class Foo with Bar ...

is an additional optional customization. 

handle_post_parsing

  Object->handle_post_parsing (Object $context, Str $package, Str | Object $name)

Allows for additional modifications to the namespace after everything else has beendone. It will receive the context, the fully qualified package name, and either astring with the name that was specified (might not be fully qualified, sincenamespaces can be nested) or the anonymous metaclass instance if no name wasspecified.

The return value of this method will be the value returned to the user of thekeyword. If you always return the $package argument like this:

  sub handle_post_parsing {      my ($self, $context, $package, $name) = @_;      return $package;  }

and set this up in a "foo" keyword handler, you can use it like this:

  foo Cthulhu {      my $fhtagn = foo Fhtagn { }      my $anon   = foo { };      say $fhtagn;  # Cthulhu::Fhtagn      say $anon;    # some autogenerated package name  }
 

make_anon_metaclass

  Class::MOP::Class Object->make_anon_metaclass ()

This method should be overridden if you want to provide anonymous namespaces.

It does not receive any arguments for customization of the metaclass, becausethe configuration and customization will be done by MooseX::Declare in thepackage of the generated class in the same way as in those that have specifiednames. This way ensures that anonymous and named namespaces are always handledequally.

If you do not extend this method (it will return nothing by default), an errorwill be thrown when a user attempts to declare an anonymous namespace. 

SEE ALSO

*
MooseX::Declare
*
MooseX::Declare::Syntax::MooseSetup
 

AUTHOR

Florian Ragwitz <raflAATTdebian.org> 

COPYRIGHT AND LICENSE

This software is copyright (c) 2008 by Florian Ragwitz.

This is free software; you can redistribute it and/or modify it underthe same terms as the Perl 5 programming language system itself.


 

Index

NAME
VERSION
DESCRIPTION
METHODS
parse
CONSUMES
REQUIRED METHODS
handle_missing_block
EXTENDABLE STUB METHODS
add_namespace_customizations
add_optional_customizations
handle_post_parsing
make_anon_metaclass
SEE ALSO
AUTHOR
COPYRIGHT AND LICENSE

This document was created byman2html,using the manual pages.