1MooseX::Declare::ContexUts(e3rpmC)ontributed Perl DocumeMnotoasteiXo:n:Declare::Context(3pm)
2
3
4

NAME

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

VERSION

9       version 0.43
10

DESCRIPTION

12       This is not a subclass of Devel::Declare::Context::Simple, but it will
13       delegate all default methods and extend it with some attributes and
14       methods of its own.
15
16       A context object will be instantiated for every keyword that is handled
17       by MooseX::Declare. If handlers want to communicate with other handlers
18       (for example handlers that will only be setup inside a namespace block)
19       it must do this via the generated code.
20
21       In addition to all the methods documented here, all methods from
22       Devel::Declare::Context::Simple are available and will be delegated to
23       an internally stored instance of it.
24

ATTRIBUTES

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

METHODS

48   add_preamble_code_parts(CodePart @parts)
49         Object->add_preamble_code_parts (CodeRef @parts)
50
51       See "add_cleanup_code_parts".
52
53   add_scope_code_parts(CodePart @parts)
54         Object->add_scope_code_parts    (CodeRef @parts)
55
56       See "add_cleanup_code_parts".
57
58   add_cleanup_code_parts(CodePart @parts)
59         Object->add_cleanup_code_parts  (CodeRef @parts)
60
61       For these three methods please look at the corresponding *_code_parts
62       attribute in the list above. These methods are merely convenience
63       methods that allow adding entries to the code part containers.
64
65   inject_code_parts_here
66         True Object->inject_code_parts_here (CodePart @parts)
67
68       Will inject the passed "CodePart"s at the current position in the code.
69
70   peek_next_char
71         Str Object->peek_next_char ()
72
73       Will return the next char without stripping it from the stream.
74
75   inject_code_parts
76         Object->inject_code_parts (
77             Bool    :$inject_cleanup_code_parts,
78             CodeRef :$missing_block_handler
79         )
80
81       This will inject the code parts from the attributes above at the
82       current position. The preamble and scope code parts will be inserted
83       first. Then then call to the cleanup code will be injected, unless the
84       options contain a key named "inject_cleanup_code_parts" with a false
85       value.
86
87       The "inject_if_block" method will be called if the next char is a "{"
88       indicating a following block.
89
90       If it is not a block, but a semi-colon is found and the options
91       contained a "missing_block_handler" key was passed, it will be called
92       as method on the context object with the code to inject and the options
93       as arguments. All options that are not recognized are passed through to
94       the "missing_block_handler". You are well advised to prefix option
95       names in your extensions.
96

TYPES

98   BlockCodePart
99       An "ArrayRef" with at least one element that stringifies to either
100       "BEGIN" or "END". The other parts will be stringified and used as the
101       body for the generated block. An example would be this compiletime role
102       composition:
103
104         ['BEGIN', 'with q{ MyRole }']
105
106   CodePart
107       A part of code represented by either a "Str" or a "BlockCodePart".
108

SEE ALSO

110       ·   MooseX::Declare
111
112       ·   Devel::Declare
113
114       ·   Devel::Declare::Context::Simple
115

AUTHOR

117       Florian Ragwitz <rafl@debian.org>
118
120       This software is copyright (c) 2008 by Florian Ragwitz.
121
122       This is free software; you can redistribute it and/or modify it under
123       the same terms as the Perl 5 programming language system itself.
124
125
126
127perl v5.28.1                      2015-08-16     MooseX::Declare::Context(3pm)
Impressum