1MooseX::Declare::ContexUts(e3r)Contributed Perl DocumentMaotoisoenX::Declare::Context(3)
2
3
4

NAME

6       MooseX::Declare::Context - Per-keyword declaration context
7

DESCRIPTION

9       This is not a subclass of Devel::Declare::Context::Simple, but it will
10       delegate all default methods and extend it with some attributes and
11       methods of its own.
12
13       A context object will be instanciated for every keyword that is handled
14       by MooseX::Declare. If handlers want to communicate with other handlers
15       (for example handlers that will only be setup inside a namespace block)
16       it must do this via the generated code.
17

TYPES

19   CodePart
20       A part of code represented by either a "Str" or a "BlockCodePart".
21
22   BlockCodePart
23       An "ArrayRef" with at least one element that stringifies to either
24       "BEGIN" or "END". The other parts will be stringified and used as the
25       body for the generated block. An example would be this compiletime role
26       composition:
27
28         ['BEGIN', 'with q{ MyRole }']
29

ATTRIBUTES

31   caller_file
32       A required "Str" containing the file the keyword was encountered in.
33
34   preamble_code_parts
35       An "ArrayRef" of "CodePart"s that will be used as preamble. A preamble
36       in this context means the beginning of the generated code.
37
38   scope_code_parts
39       These parts will come before the actual body and after the
40       "preamble_code_parts". It is an "ArrayRef" of "CodePart"s.
41
42   cleanup_code_parts
43       An "ArrayRef" of "CodePart"s that will not be directly inserted into
44       the code, but instead be installed in a handler that will run at the
45       end of the scope so you can do namespace cleanups and such.
46
47   stack
48       An "ArrayRef" that contains the stack of handlers. A keyword that was
49       only setup inside a scoped block will have the blockhandler be put in
50       the stack.
51

METHODS

53       All methods from Devel::Declare::Context::Simple should be available
54       and will be delegated to an internally stored instance of it.
55
56   add_preamble_code_parts(CodePart @parts)
57   add_scope_code_parts(CodePart @parts)
58   add_cleanup_code_parts(CodePart @parts)
59         Object->add_preamble_code_parts (CodeRef @parts)
60         Object->add_scope_code_parts    (CodeRef @parts)
61         Object->add_cleanup_code_parts  (CodeRef @parts)
62
63       For these three methods please look at the corresponding *_code_parts
64       attribute in the list above. These methods are merely convenience
65       methods that allow adding entries to the code part containers.
66
67   inject_code_parts_here
68         True Object->inject_code_parts_here (CodePart @parts)
69
70       Will inject the passed "CodePart"s at the current position in the code.
71
72   peek_next_char
73         Str Object->peek_next_char ()
74
75       Will return the next char without stripping it from the stream.
76
77   inject_code_parts
78         Object->inject_code_parts (
79             Bool    :$inject_cleanup_code_parts,
80             CodeRef :$missing_block_handler
81         )
82
83       This will inject the code parts from the attributes above at the
84       current position. The preamble and scope code parts will be inserted
85       first. Then then call to the cleanup code will be injected, unless the
86       options contain a key named "inject_cleanup_code_parts" with a false
87       value.
88
89       The "inject_if_block" method will be called if the next char is a "{"
90       indicating a following block.
91
92       If it is not a block, but a semi-colon is found and the options
93       contained a "missing_block_handler" key was passed, it will be called
94       as method on the context object with the code to inject and the options
95       as arguments. All options that are not recognized are passed through to
96       the "missing_block_handler". You are well advised to prefix option
97       names in your extensions.
98
99   strip_name_and_options
100         List Object->strip_name_and_options ()
101
102       This will remove an identifier plus any options that follow it from the
103       stream. Options are things like "is Trait", "with Role" and "extends
104       ParentClass". Currently, only these are supported.
105
106       The return value is a list with two values:
107
108       Str $name
109           The name that was read.
110
111       HashRef $options
112           The options that followed the name. This is the returned format:
113
114             Dict[
115                 is      => HashRef[Bool],
116                 extends => ArrayRef[ParentClass],
117                 with    => ArrayRef[Role],
118             ]
119

SEE ALSO

121       ·   MooseX::Declare
122
123       ·   Devel::Declare
124
125       ·   Devel::Declare::Context::Simple
126
128       See MooseX::Declare
129
130
131
132perl v5.12.1                      2009-12-19       MooseX::Declare::Context(3)
Impressum