1MooseX::Declare::SyntaxU:s:eNramCeosnptarMcioeboHusateneXdd:l:iPDneegrc(ll3apDrmoe)c:u:mSeynnttaatxi:o:nNamespaceHandling(3pm)
2
3
4

NAME

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

VERSION

9       version 0.43
10

DESCRIPTION

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

METHODS

20   parse
21         Any Object->parse (Object $context)
22
23       This is the main handling routine for namespaces. It will remove the
24       namespace name and its options. If the handler was invoked without a
25       name, options or a following block, it is assumed that this is an
26       instance of an autoquoted bareword like "class => "Foo"".
27
28       The return value of the "parse" method is also the value that is
29       returned to the user of the keyword.
30

CONSUMES

32       •   MooseX::Declare::Syntax::KeywordHandling
33
34       •   MooseX::Declare::Syntax::InnerSyntaxHandling
35

REQUIRED METHODS

37   handle_missing_block
38         Object->handle_missing_block (Object $context, Str $body, %args)
39
40       This must be implemented to decide what to do in case the statement is
41       terminated rather than followed by a block. It will receive the context
42       object, the produced code that needs to be injected, and all the
43       arguments that were passed to the call to "inject_code_parts" in
44       MooseX::Declare::Context.
45
46       The return value will be ignored.
47

EXTENDABLE STUB METHODS

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

SEE ALSO

118       •   MooseX::Declare
119
120       •   MooseX::Declare::Syntax::MooseSetup
121

AUTHOR

123       Florian Ragwitz <rafl@debian.org>
124
126       This software is copyright (c) 2008 by Florian Ragwitz.
127
128       This is free software; you can redistribute it and/or modify it under
129       the same terms as the Perl 5 programming language system itself.
130
131
132
133perl v5.34.0                   Moo2s0e2X2:-:0D1e-c2l1are::Syntax::NamespaceHandling(3pm)
Impressum