1MooseX::Declare::SyntaxU:s:eNramCeosnptarciebMHuoatonesddelXiP:ne:grD(le3c)Dloacruem:e:nStyanttiaoxn::NamespaceHandling(3)
2
3
4

NAME

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

DESCRIPTION

9       Allows the implementation of namespaced blocks like the role and class
10       keyword handlers.
11
12       Namespaces are automatically nested. Meaning that, for example, a
13       "class Bar" declaration inside another "class Foo" block gives the
14       inner one actually the name "Foo::Bar".
15

CONSUMES

17       ·   MooseX::Declare::Syntax::KeywordHandling
18
19       ·   MooseX::Declare::Syntax::InnerSyntaxHandling
20

REQUIRED METHODS

22   handle_missing_block
23         Object->handle_missing_block (Object $context, Str $body, %args)
24
25       This must be implemented to decide what to do in case the statement is
26       terminated rather than followed by a block. It will receive the context
27       object, the produced code that needs to be injected, and all the
28       arguments that were passed to the call to "inject_code_parts" in
29       MooseX::Declare::Context.
30
31       The return value will be ignored.
32

EXTENDABLE STUB METHODS

34   add_namespace_customizations
35   add_optional_customizations
36         Object->add_namespace_customizations (Object $context, Str $package, HashRef $options)
37         Object->add_optional_customizations  (Object $context, Str $package, HashRef $options)
38
39       These will be called (in this order) by the "parse" method. They allow
40       specific hooks to attach before/after/around the customizations for the
41       namespace and the provided options that are not attached to the
42       namespace directly.
43
44       While this distinction might seem superficial, we advise library
45       developers faciliating this role to follow the precendent. This ensures
46       that when another component needs to tie between the namspace and any
47       additional customizations everythign will run in the correct order. An
48       example of this separation would be
49
50         class Foo is mutable ...
51
52       being an option of the namespace generation, while
53
54         class Foo with Bar ...
55
56       is an additional optional customization.
57
58   handle_post_parsing
59         Object->handle_post_parsing (Object $context, Str $package, Str | Object $name)
60
61       Allows for additional modifications to te namespace after everything
62       else has been done. It will receive the context, the fully qualified
63       package name, and either a string with the name that was specified
64       (might not be fully qualified, since namespaces can be nested) or the
65       anonymous metaclass instance if no name was specified.
66
67       The return value of this method will be the value returned to the user
68       of the keyword. If you always return the $package argument like this:
69
70         sub handle_post_parsing {
71             my ($self, $context, $package, $name) = @_;
72             return $package;
73         }
74
75       and set this up in a "foo" keyword handler, you can use it like this:
76
77         foo Cthulhu {
78
79             my $fhtagn = foo Fhtagn { }
80             my $anon   = foo { };
81
82             say $fhtagn;  # Cthulhu::Fhtagn
83             say $anon;    # some autogenerated package name
84         }
85
86   make_anon_metaclass
87         Class::MOP::Class Object->make_anon_metaclass ()
88
89       This method should be overridden if you want to provide anonymous
90       namespaces.
91
92       It does not receive any arguments for customization of the metaclass,
93       because the configuration and customization will be done by
94       MooseX::Declare in the package of the generated class in the same way
95       as in those that have specified names. This way ensures that anonymous
96       and named namespaces are always handled equally.
97
98       If you do not extend this method (it will return nothing by default),
99       an error will be thrown when a user attempts to declare an anonymous
100       namespace.
101

METHODS

103   parse
104         Any Object->parse (Object $context)
105
106       This is the main handling routine for namespaces. It will remove the
107       namespace name and its options. If the handler was invoked without a
108       name, options or a following block, it is assumed that this is an
109       instance of an autoquoted bareword like "class =" "Foo">.
110
111       The return value of the "parse" method is also the value that is
112       returned to the user of the keyword.
113

SEE ALSO

115       ·   MooseX::Declare
116
117       ·   MooseX::Declare::Syntax::MooseSetup
118
120       See MooseX::Declare
121
122
123
124perl v5.12.1                     M2o0o0s9e-X0:9:-D2e2clare::Syntax::NamespaceHandling(3)
Impressum