blib/lib/MooseX/OmniTrigger.pm

filter: Statementstmt 98.7% 230 / 233 Branchbran 80.4% 37 / 46 Conditioncond 83.7% 36 / 43 MC/DCmcdc 62.5% 15 / 24 Subroutinesub 98.1% 52 / 53 Podpod 0.0% 0 / 6 totaltotal 91.3% 370 / 405 CC 45 SCAR 16.4
CC
45
Cov
94%
_fire_omnitrigger
18.0
_icode_fire_omnitrigger
6.0
__ANON__
5.6
CRAP 5.1
↑ Summary
1 14 ▶use strict; use warnings; use warnings (FATAL => qw(misc numeric uninitialized)); # use autodie;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 14 ▶use Class::Load ();
Subroutine BEGIN: called CC=1 SCAR=0.0
4 14 ▶use Hash::Util::FieldHash ();
Subroutine BEGIN: called CC=1 SCAR=0.0
5 14 ▶use Moose 2.0200 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 14 ▶use Moose::Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 14 ▶use Moose::Util::MetaRole ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 { package MooseX::OmniTrigger;
10  
11 14 our $VERSION = '0.06';
12  
13 14 Moose::Exporter->setup_import_methods;
14  
15 14 ▶ my (undef, undef, $init_meta_method) = Moose::Exporter->build_import_methods(
Branch: 1 branch
BranchTrueFalseTotal
'Moose'->VERSION >= 1.99 ? : 14 0 14
16  
17 install => [qw(import unimport)],
18  
19 role_metaroles => {
20  
21 role => [qw(MooseX::OmniTrigger::MetaRole::Role)],
22  
23 Moose->VERSION >= 1.9900 ? (applied_attribute => [qw(MooseX::OmniTrigger::MetaRole::Attribute)]) : (),
24  
25 application_to_role => [qw(MooseX::OmniTrigger::MetaRole::AppToRole )],
26 application_to_class => [qw(MooseX::OmniTrigger::MetaRole::AppToClass)],
27 },
28  
29 class_metaroles => {
30  
31 class => [qw(MooseX::OmniTrigger::MetaRole::Class )],
32 attribute => [qw(MooseX::OmniTrigger::MetaRole::Attribute)],
33 instance => [qw(MooseX::OmniTrigger::MetaRole::Instance )],
34 },
35 );
36  
37 20 ▶ sub init_meta { goto $init_meta_method }
Subroutine init_meta: called CC=1 SCAR=0.0
Pod undocumented
38 }
39  
40 14 { package MooseX::OmniTrigger::MetaRole::Role;
41  
42 14 ▶ use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 1 ▶ around composition_class_roles => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
45  
46 1 my ($orig_method, $self) = (shift, shift);
47  
48 1 return ($self->$orig_method(@_), 'MooseX::OmniTrigger::MetaRole::Composite');
49 14 };
50 }
51  
52 14 { package MooseX::OmniTrigger::MetaRole::Composite;
53  
54 14 ▶ use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
55  
56 1 ▶ around apply_params => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
57  
58 1 my ($orig_method, $self) = (shift, shift);
59  
60 1 $self->$orig_method(@_);
61  
62 1 $self = Moose::Util::MetaRole::apply_metaroles(
63  
64 for => $self,
65  
66 role_metaroles => {
67  
68 application_to_class => [qw(MooseX::OmniTrigger::MetaRole::AppToClass)],
69 application_to_role => [qw(MooseX::OmniTrigger::MetaRole::AppToRole )],
70 },
71 );
72  
73 1 return $self;
74 14 };
75 }
76  
77 14 { package MooseX::OmniTrigger::MetaRole::AppToClass;
78  
79 14 ▶ use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
80  
81 6 ▶ around apply => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
82  
83 6 my ($orig_method, $self, $role, $applicant) = (shift, shift, @_);
84  
85 6 $applicant = Moose::Util::MetaRole::apply_metaroles(
86  
87 for => $applicant,
88  
89 class_metaroles => {
90  
91 class => [qw(MooseX::OmniTrigger::MetaRole::Class )],
92 instance => [qw(MooseX::OmniTrigger::MetaRole::Instance)],
93 },
94 );
95  
96 6 $self->$orig_method($role, $applicant);
97  
98 # NO EXPLICIT RETVAL.
99 14 };
100 }
101  
102 14 { package MooseX::OmniTrigger::MetaRole::AppToRole;
103  
104 14 ▶ use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
105  
106 3 ▶ around apply => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
107  
108 3 my ($orig_method, $self, $role, $applicant) = (shift, shift, @_);
109  
110 3 $applicant = Moose::Util::MetaRole::apply_metaroles(
111  
112 for => $applicant,
113  
114 role_metaroles => {
115  
116 application_to_class => [qw(MooseX::OmniTrigger::MetaRole::AppToClass)],
117 application_to_role => [qw(MooseX::OmniTrigger::MetaRole::AppToRole )],
118 },
119 );
120  
121 3 $self->$orig_method($role, $applicant);
122  
123 # NO EXPLICIT RETVAL.
124 14 };
125 }
126  
127 14 ▶{ package MooseX::OmniTrigger::State; use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
128  
129 14 ▶ use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
130  
131 14 Hash::Util::FieldHash::fieldhash(my %state);
132  
133 1547 ▶ { my $state; sub singleton { $state ||= __PACKAGE__->new } }
Subroutine singleton: called CC=2 SCAR=7.1
Pod undocumented
Condition66%2/3
$state ||= __PACKAGE__->new
l!l&&r!l&&!r
1533140
MC/DC0%0/2
$state ||= __PACKAGE__->new
$state __PACKAGE__->new
Truth table66%2/3
A ||= B
A= $stateB= __PACKAGE__->new
ABresult
1X1
011
000
134  
135 792 ▶ sub instance { $state{$_[1]} ||= {} }
Subroutine instance: called CC=2 SCAR=6.9
Pod undocumented
Condition100%2/2
$state{$_[1]} ||= {}
l!l
76032
MC/DC100%1/1
$state{$_[1]} ||= {}
$state{$_[1]}
Truth table100%2/2
A
A= $state{$_[1]}
Aresult
11
00
136 968 ▶ sub slot { $state{$_[1]}{SLOT_NAME}{ref($_[2]) ? $_[2]->name : $_[2]} ||= {} }
Subroutine slot: called CC=3 SCAR=11.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
ref $_[2] ? : 496 472 968
Condition100%2/2
$state{$_[1]}{"SLOT_NAME"}{ref $_[2] ? $_[2]->name : $_[2]} ||= {}
l!l
675293
MC/DC100%1/1
$state{$_[1]}{"SLOT_NAME"}{ref $_[2] ? $_[2]->name : $_[2]} ||= {}
$state{$_[1]}{"SLOT_NAME"}{ref $_[2] ? $_[2]->name : $_[2]}
Truth table100%2/2
A
A= $state{$_[1]}{"SLOT_NAME"}{ref $_[2] ? $_[2]->name : $_[2]}
Aresult
11
00
137  
138 10 ▶ sub reset {
Subroutine reset: called CC=5 SCAR=16.1
Pod undocumented
139  
140 # CALLED JUST BEFORE THE ORIG MM::Class::_fixup_attributes_after_rebless AND JUST AFTER THE
141 # ORIG CMOP::Instance::clone_instance. WIPES OUT INSTANCE/SLOT STATE FOR $instance AND THEN
142 # ESTABLISHES oldval_at_reset AND initval_at_reset FOR EACH $instance SLOT.
143  
144 10 my ($self, $instance, $params) = @_;
145  
146 10 delete($state{$instance});
147  
148 10 for my $attr (Moose::Util::find_meta($instance)->_get_all_attrs_that_have_omnitrigs) {
149  
150 43 my $slot_state = $self->slot($instance, $attr);
151  
152 43 ▶ $slot_state->{oldval_at_reset} = [$attr->has_value($instance) ? $attr->get_raw_value($instance) : ()];
Branch: 1 branch
BranchTrueFalseTotal
$attr->has_value($instance) ? : 20 23 43
153  
154 43 ▶ $slot_state->{initval_at_reset} = [exists($params->{$attr->init_arg || ''}) ? $params->{$attr->init_arg} : ()];
Branch: 1 branch
BranchTrueFalseTotal
exists $$params{$attr->init_arg or ''} ? : 12 31 43
Condition100%2/2
$attr->init_arg || ''
l!l
421
MC/DC100%1/1
$attr->init_arg || ''
$attr->init_arg
Truth table100%2/2
A
A= $attr->init_arg
Aresult
11
00
155 }
156  
157 # NO EXPLICIT RETVAL.
158 }
159  
160 4 ▶ sub _test_me { \%state }
Subroutine _test_me: called CC=1 SCAR=0.0
161  
162 14 __PACKAGE__->meta->make_immutable;
163 }
164  
165 14 ▶{ package MooseX::OmniTrigger::MetaRole::Class; use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
166  
167 14 ▶ use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
168  
169 2 ▶ around clone_object => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
170  
171 # MOOSE DOESN'T HANDLE TRIGGERS DURING OBJECT CLONING THE SAME AS IT DOES DURING REGULAR
172 # CONSTRUCTION. call_all_triggers ISN'T USED. CMOP LOOPS OVER ALL ATTRIBUTES AND SETS ANY
173 # NEW INITVALS VIA set_value IMMEDIATELY AFTER THE CLONING OF THE INSTANCE; AND ANY MOOSE
174 # TRIGGERS ARE FIRED AS USUAL WITH EACH set_value CALL. (THUS THE *BEHAVIOR* FOR TRIGGERS IS
175 # CONSISTENT BETWEEN NORMAL CONSTRUCTION AND CLONING, BUT THE IMPLEMENTATION ISN'T.)
176  
177 # FOR OMNITRIGGERS, WE TREAT CLONE CONSTRUCTION IN BLACK-BOX FASHION JUST AS WE DO WITH
178 # NORMAL CONSTRUCTION AND REBLESS FIXUP.
179  
180 2 my ($orig_method, $self_aka_class, undef, %params) = (shift, shift, @_);
181  
182 2 my $clone = $self_aka_class->$orig_method(@_);
183  
184 2 $self_aka_class->_call_all_omnitriggers($clone, \%params);
185  
186 2 return $clone;
187 14 };
188  
189 8 ▶ around _fixup_attributes_after_rebless => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
190  
191 8 my ($orig_method, $self_aka_class, $instance, undef, %params) = (shift, shift, @_);
192  
193 8 my $state = MooseX::OmniTrigger::State->singleton;
194  
195 8 $state->reset($instance, \%params);
196  
197 8 local $state->instance($instance)->{fixing_up} = 1;
198  
199 8 $self_aka_class->$orig_method(@_);
200  
201 # NO EXPLICIT RETVAL.
202 14 };
203  
204 36 ▶ around _call_all_triggers => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
205  
206 36 my ($orig_method, $self_aka_class, $instance) = (shift, shift, @_);
207  
208 36 MooseX::OmniTrigger::State->singleton->instance($instance)->{omnitrigs_ready} = 1;
209  
210 36 $self_aka_class->$orig_method(@_);
211  
212 36 $self_aka_class->_call_all_omnitriggers(@_);
213  
214 # NO EXPLICIT RETVAL.
215 14 };
216  
217 38 ▶ sub _call_all_omnitriggers {
Subroutine _call_all_omnitriggers: called CC=4 SCAR=13.9
218  
219 38 my ($self_aka_class, $instance, $params) = @_;
220  
221 38 my $state = MooseX::OmniTrigger::State->singleton;
222  
223 #===========================================================================================
224 # TO THIS POINT, $instance HAS BEEN IN A STATE OF CONSTRUCTION, CLONING, OR FIXUP.
225 # omnitrigs_ready WILL HAVE BEEN FALSE, AND OMNITRIGGERS WILL NOT HAVE BEEN ALLOWED TO FIRE.
226  
227 38 $state->instance($instance)->{omnitrigs_ready} = 1;
228  
229 #
230 #===========================================================================================
231  
232 38 ATTRIBUTE: for my $attr ($self_aka_class->_get_all_attrs_that_have_omnitrigs) {
233  
234 176 my $slot_state = $state->slot($instance, $attr);
235  
236 #=======================================================================================
237 # WE NEED TO FIRE THIS OMNITRIGGER NOW ONLY IF AN ATTEMPT TO FIRE IT WAS MADE DURING
238 # CONSTRUCTION/CLONING/FIXUP (AND ONLY IF IT HASN'T BEEN FIRED SINCE THAT ATTEMPT).
239  
240 176 ▶ next ATTRIBUTE unless $slot_state->{fire_omnitrig_when_ready};
Branch: 1 branch
BranchTrueFalseTotal
unless $slot_state->{"fire_omnitrig_when_ready"} 85 91 176
241  
242 #
243 #=======================================================================================
244  
245 #=======================================================================================
246 # THE OLDVAL IS WHATEVER IT WAS *PRIOR* TO CONSTRUCTION/FIXUP, EVEN THOUGH THAT VALUE
247 # DOESN'T NECESSARILY MATCH WHAT'S IN THE SLOT AT THIS EXACT MOMENT.
248  
249 $attr->_fire_omnitrigger({
250  
251 instance => $instance,
252  
253 91 ▶ oldval => [@{$slot_state->{oldval_at_reset} || []}],
Condition100%2/2
$slot_state->{'oldval_at_reset'} || []
l!l
1873
MC/DC100%1/1
$slot_state->{'oldval_at_reset'} || []
$slot_state->{'oldval_at_reset'}
Truth table100%2/2
A
A= $slot_state->{'oldval_at_reset'}
Aresult
11
00
254 });
255 }
256  
257 # NO EXPLICIT RETVAL.
258 }
259  
260 80 ▶ sub _get_all_attrs_that_have_omnitrigs {
Subroutine _get_all_attrs_that_have_omnitrigs: called CC=2 SCAR=7.0
261  
262 80 my ($self_aka_class) = @_;
263  
264 80 my @attributes = $self_aka_class->get_all_attributes;
265  
266 80 ▶ @attributes = grep($_->can('has_omnitrigger') && $_->has_omnitrigger, @attributes);
Condition66%2/3
$_->can('has_omnitrigger') && $_->has_omnitrigger
!ll&&!rl&&r
070423
MC/DC50%1/2
$_->can('has_omnitrigger') && $_->has_omnitrigger
$_->can('has_omnitrigger') $_->has_omnitrigger
Truth table66%2/3
A && B
A= $_->can('has_omnitrigger')B= $_->has_omnitrigger
ABresult
0X0
100
111
267  
268 80 @attributes = sort({ $a->omnitrig_sort_key cmp $b->omnitrig_sort_key } @attributes);
269  
270 80 return @attributes;
271 }
272  
273 16 ▶ around _eval_environment => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
274  
275 16 my ($orig_method, $self_aka_class) = (shift, shift);
276  
277 # IT APPEARS THAT CMOP AND MOOSE TAKE SOME PAINS TO AVOID USING HASHES AS EE VARS, PROBABLY
278 # FOR PERFORMANCE. WE'LL USE HASHES, THOUGH (HERE AND WHERE WE WRAP _eval_environment IN
279 # MooseX::OmniTrigger::MetaRole::Attribute), BECAUSE IT MAKES IT EASIER TO GET SOME REUSE
280 # OUT OF _icode_fire_omnitrigger.
281  
282 16 my @attrs = $self_aka_class->_get_all_attrs_that_have_omnitrigs;
283  
284 return {
285  
286 16 %{$self_aka_class->$orig_method(@_)},
287  
288 '%_EE_OMNITRIG_attrs_init_arg' => {map(($_->name => $_->init_arg ), @attrs)},
289 '%_EE_OMNITRIG_attrs_omnitrigger' => {map(($_->name => $_->omnitrigger), @attrs)},
290 };
291 14 };
292  
293 16 ▶ around _inline_triggers => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
294  
295 16 my ($orig_method, $self_aka_class) = (shift, shift);
296  
297 #===========================================================================================
298 # WE HARDCODE THE EXPRESSION '$instance' BECAUSE _inline_triggers HARDCODES IT, HAVING NOT
299 # RECEIVED IT AS AN ARGUMENT. (WHICH PROBABLY IT SHOULD HAVE? IT WAS AVAILABLE AS EARLY AS
300 # _inline_new_object.)
301  
302 16 my $iexpr_instance = '$instance';
303  
304 #
305 #===========================================================================================
306  
307 return ( # ORIG METHOD RETURNS CODE AS LIST.
308  
309 "MooseX::OmniTrigger::State->singleton->instance($iexpr_instance)->{omnitrigs_ready} = 1;",
310  
311 $self_aka_class->$orig_method(@_),
312  
313 16 @{$self_aka_class->icode_call_all_omnitriggers({
314  
315 iexpr_instance => $iexpr_instance,
316 })},
317 );
318 14 };
319  
320 16 ▶ sub icode_call_all_omnitriggers {
Subroutine icode_call_all_omnitriggers: called CC=2 SCAR=6.9
Pod undocumented
321  
322 # SEE COMMENTS IN _call_all_triggers.
323  
324 16 my ($self_aka_class, $p) = (shift, @_);
325  
326 16 my @icode_call_all_omnitriggers; for my $attr ($self_aka_class->_get_all_attrs_that_have_omnitrigs) {
327  
328 102 my $attr_name = $attr->name;
329  
330 push(@icode_call_all_omnitriggers,
331 'ATTRIBUTE: {',
332  
333 "my \$_OMNITRIG_slot_state = MooseX::OmniTrigger::State->singleton->slot($p->{iexpr_instance}, '$attr_name');",
334  
335 "next ATTRIBUTE unless \$_OMNITRIG_slot_state->{fire_omnitrig_when_ready};",
336  
337 102 @{$attr->_icode_fire_omnitrigger({
338  
339 iexpr_slot_state => '$_OMNITRIG_slot_state',
340  
341 iexpr_instance => $p->{iexpr_instance},
342  
343 102 iexpr_oldval => "[\@{\$_OMNITRIG_slot_state->{oldval_at_reset} || []}]",
344 })},
345 '}',
346 );
347 }
348  
349 16 return \@icode_call_all_omnitriggers;
350 }
351 }
352  
353 14 ▶{ package MooseX::OmniTrigger::MetaRole::Attribute; use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
354  
355 14 ▶ use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
356  
357 14 has omnitrigger => (is => 'rw', isa => 'CodeRef', predicate => 'has_omnitrigger');
358  
359 14 has omnitrig_sort_key => (required => 1, is => 'rw', isa => 'Str', default => "\0");
360  
361 277 ▶ sub _fire_omnitrigger {
Subroutine _fire_omnitrigger: called CC=17 SCAR=28.9
362  
363 277 my ($self_aka_attr, $p) = @_;
364  
365 277 my $instance_state = MooseX::OmniTrigger::State->singleton->instance($p->{instance} );
366 277 my $slot_state = MooseX::OmniTrigger::State->singleton->slot ($p->{instance}, $self_aka_attr);
367  
368 277 my $omnitrig_is_recursing = $slot_state->{omnitrig_is_recursing};
369  
370 277 local $slot_state->{omnitrig_is_recursing} = 1;
371  
372 277 ▶ if ($omnitrig_is_recursing) {
Branch: 1 branch
BranchTrueFalseTotal
if ($omnitrig_is_recursing) 0 277 277
373  
374 0 ▶ $p->{sub_to_wrap}() if $p->{sub_to_wrap};
Branch: 1 branch
BranchTrueFalseTotal
if $p->{"sub_to_wrap"} 0 0 0
375  
376 0 return;
377 }
378  
379 277 ▶ unless ($instance_state->{omnitrigs_ready}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($instance_state->{"omnitrigs_ready"}) 112 165 277
380  
381 # A FALSE omnitrigs_ready MEANS THE INSTANCE IS BEING CONSTRUCTED, CLONED, OR FIXED UP
382 # AND _call_all_triggers HAS NOT YET BEEN HIT. OMNITRIGGERS ARE NOT ALLOWED TO FIRE AT
383 # THIS TIME. HOWEVER, WE DO SET A FLAG INDICATING THAT THIS OMNITRIGGER SHOULD FIRE WHEN
384 # omnitrigs_ready DOES BECOME TRUE.
385  
386 #=======================================================================================
387 # THERE'S A SPECIAL CASE, WHEN WE'RE HERE AS THE RESULT OF A SLOT BEING SET DURING FIXUP
388 # FOR THE PURPOSE OF "TRANSFERRING" A VALUE FROM THE "OLD" INSTANCE TO THE "NEW." WE
389 # DON'T COUNT SUCH A TRANSFER AS A *CHANGE*: IT'S JUST BOOKKEEPING. SO FOR THESE
390 # TRANSFERS WE NEITHER FIRE THE OMNITRIGGER NOW NOR SET fire_omnitrig_when_ready TRUE
391 # FOR A FUTURE FIRING.
392  
393 # KLUDGY SOLUTION, THE unless CONDITION, HERE. I FINALLY HAD TO DO SOMETHING LIKE THIS
394 # BECAUSE OF THE WAY _fixup_attributes_after_rebless IS IMPLEMENTED. THERE ARE BASICALLY
395 # THREE DIFFERENT SCENARIOS THERE: 1) EXISTING VALUES OF ATTRIBUTES WITH UNDEFINED
396 # init_argS ARE TRANSFERRED VIA set_value; 2) EXISTING VALUES OF ATTRIBUTES WITH DEFINED
397 # init_argS ARE TRANSFERRED VIA set_initial_value; AND 3) NEWLY INCOMING VALUES FOR
398 # ATTRIBUTES WITH DEFINED init_argS ARE SET VIA set_initial_value. WE NORMALLY FIRE
399 # OMNITRIGGERS FOR ANY USE OF set_value OR set_initial_value (RATHER,
400 # _set_initial_slot_value, ULTIMATELY), BUT HERE OMNITRIGGERS SHOULD FIRE ONLY FOR THAT
401 # THIRD SCENARIO. AS MOOSE GIVES NO WAY EXPLICITLY TO ISOLATE "SET-FOR-THE- PURPOSE-OF-
402 # TRANSFER" OPERATIONS, WE'VE GOT TO ISOLATE (AND AVOID) THEM MORE CIRCUITOUSLY.
403  
404 $slot_state->{fire_omnitrig_when_ready} = 1
405 112 ▶ unless $instance_state->{fixing_up} && @{$slot_state->{oldval_at_reset} || []} && ! @{$slot_state->{initval_at_reset} || []};
Branch: 1 branch
BranchTrueFalseTotal
unless $instance_state->{"fixing_up"} and @{$slot_state->{"oldval_at_reset"} or [];} and not @{$slot_state->{"initval_at_reset"} or [];} 99 13 112
Condition80%8/10
$instance_state->{"fixing_up"} and @{$slot_state->{"oldval_at_reset"} or [];} and not @{$slot_state->{"initval_at_reset"} or [];}
!ll&&!rl&&r
94513
$instance_state->{"fixing_up"} and @{$slot_state->{"oldval_at_reset"} or [];}
!ll&&!rl&&r
831118
$slot_state->{'oldval_at_reset'} || []
l!l
290
$slot_state->{'initval_at_reset'} || []
l!l
180
MC/DC100%3/3
$instance_state->{"fixing_up"} and @{$slot_state->{"oldval_at_reset"} or [];} and not @{$slot_state->{"initval_at_reset"} or [];}
$instance_state->{"fixing_up"} @{$slot_state->{"oldval_at_reset"} or [];} not @{$slot_state->{"initval_at_reset"} or [];}
MC/DC0%0/1
$slot_state->{'oldval_at_reset'} || []
$slot_state->{'oldval_at_reset'}
MC/DC0%0/1
$slot_state->{'initval_at_reset'} || []
$slot_state->{'initval_at_reset'}
Truth table100%4/4
A and B and not(C)
A= $instance_state->{"fixing_up"}B= @{$slot_state->{"oldval_at_reset"} or [];}C= not @{$slot_state->{"initval_at_reset"} or [];}
ABCresult
0XX0
10X0
1100
1111
Truth table50%1/2
A
A= $slot_state->{'oldval_at_reset'}
Aresult
11
00
Truth table50%1/2
A
A= $slot_state->{'initval_at_reset'}
Aresult
11
00
406  
407 #
408 #=======================================================================================
409  
410 112 ▶ $p->{sub_to_wrap}() if $p->{sub_to_wrap};
Branch: 1 branch
BranchTrueFalseTotal
if $p->{"sub_to_wrap"} 112 0 112
411  
412 112 return;
413 }
414  
415 #===========================================================================================
416 # TO GET THE OLDVAL (AND THE NEWVAL, HERE AND ELSEWHERE), WE USE get_raw_value. WE DON'T
417 # CONSIDER IT OUR BUSINESS TO PERFORM ANY CHECKS OR COERCIONS.
418  
419 165 ▶ my $oldval = $p->{oldval} || [$self_aka_attr->has_value($p->{instance}) ? $self_aka_attr->get_raw_value($p->{instance}) : ()];
Branch: 1 branch
BranchTrueFalseTotal
$self_aka_attr->has_value($p->{'instance'}) ? : 37 37 74
Condition100%2/2
$p->{'oldval'} || [$self_aka_attr->has_value($p->{'instance'}) ? $self_aka_attr->get_raw_value($p->{'instance'}) : ()]
l!l
9174
MC/DC100%1/1
$p->{'oldval'} || [$self_aka_attr->has_value($p->{'instance'}) ? $self_aka_attr->get_raw_value($p->{'instance'}) : ()]
$p->{'oldval'}
Truth table100%2/2
A
A= $p->{'oldval'}
Aresult
11
00
420  
421 #
422 #===========================================================================================
423  
424 #===========================================================================================
425 # BEAR IN MIND THAT (HERE AND ABOVE) sub_to_wrap WILL BE UNDEF IF WE WERE CALLED FROM
426 # _call_all_triggers. IF SO, ANY ACTUAL SET OPS WILL ALREADY HAVE BEEN PERFORMED INSIDE THE
427 # CONSTRUCTION/CLONING/FIXUP "BLACK BOX."
428  
429 165 ▶ $p->{sub_to_wrap}() if $p->{sub_to_wrap};
Branch: 1 branch
BranchTrueFalseTotal
if $p->{"sub_to_wrap"} 74 91 165
430  
431 #
432 #===========================================================================================
433  
434 165 ▶ my $newval = [$self_aka_attr->has_value($p->{instance}) ? $self_aka_attr->get_raw_value($p->{instance}) : ()];
Branch: 1 branch
BranchTrueFalseTotal
$self_aka_attr->has_value($p->{'instance'}) ? : 153 12 165
435  
436 #===========================================================================================
437 # BY ITS NATURE, WEAKENING CAN OCCUR ONLY *AFTER* THE SET OP. THIS MEANS THAT, IF WE'VE
438 # WRAPPED A BASIC SETTER, WEAKENING WON'T YET HAVE HAPPENED -- WE'D EXPECT IT TO OCCUR SOME
439 # TIME AFTER _fire_omnitrigger RETURNS. BUT TO BE CORRECT AND SAFE, WE WANT ANY NECESSARY
440 # WEAKENING TO OCCUR NOW, PRIOR TO FIRING THE OMNITRIGGER.
441  
442 # DEPENDING ON WHETHER THE SETTER WE'VE WRAPPED PERFORMS WEAKENING ITSELF, THE WEAKENING
443 # HERE IS EITHER ITSELF REDUNDANT, OR IS GOING TO MAKE A FUTURE WEAKENING REDUNDANT.
444  
445 165 ▶ $self_aka_attr->_weaken_value($p->{instance}) if ref($newval->[0]) && $self_aka_attr->is_weak_ref;
Branch: 1 branch
BranchTrueFalseTotal
if ref $newval->[0] and $self_aka_attr->is_weak_ref 18 147 165
Condition100%3/3
ref $newval->[0] and $self_aka_attr->is_weak_ref
!ll&&!rl&&r
1351218
MC/DC100%2/2
ref $newval->[0] and $self_aka_attr->is_weak_ref
ref $newval->[0] $self_aka_attr->is_weak_ref
Truth table100%3/3
A and B
A= ref $newval->[0]B= $self_aka_attr->is_weak_ref
ABresult
0X0
100
111
446  
447 #
448 #===========================================================================================
449  
450 #===========================================================================================
451 # FIRE.
452  
453 165 $p->{instance}->$_($self_aka_attr->name, $newval, $oldval) for $self_aka_attr->omnitrigger;
454  
455 #
456 #===========================================================================================
457  
458 #===========================================================================================
459 # IF WE'RE IN _call_all_omnitriggers, AND IF THIS OMNITRIGGER HASN'T YET BEEN "ARTIFICIALLY"
460 # FIRED INSIDE THE "ATTRIBUTE" LOOP THERE, WE NOW WANT TO MAKE SURE AN ARTIFICIAL FIRING
461 # NEVER HAPPENS. THE FIRING THAT JUST OCCURRED, WHATEVER THE REASON FOR IT, SATISFIES THE
462 # fire_omnitrigger_when_ready REQUIREMENT, AND AN ARTIFICIAL FIRING WOULD NOW BE REDUNDANT
463 # AND INCORRECT.
464  
465 165 delete($slot_state->{fire_omnitrig_when_ready});
466  
467 #
468 #===========================================================================================
469  
470 # NO EXPLICIT RETVAL.
471 }
472  
473 233 ▶ around _eval_environment => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
474  
475 233 my ($orig_method, $self_aka_attr) = (shift, shift);
476  
477 233 my $attr_name = $self_aka_attr->name;
478  
479 return {
480  
481 233 %{$self_aka_attr->$orig_method(@_)},
482  
483 '%_EE_OMNITRIG_attrs_init_arg' => {$attr_name => $self_aka_attr->init_arg },
484 '%_EE_OMNITRIG_attrs_omnitrigger' => {$attr_name => $self_aka_attr->omnitrigger},
485 };
486 14 };
487  
488 470 ▶ sub _icode_fire_omnitrigger {
Subroutine _icode_fire_omnitrigger: called CC=6 SCAR=17.9
489  
490 470 my ($self_aka_attr, $p) = @_;
491  
492 470 my $attr_name = $self_aka_attr->name;
493  
494 my $iexpr_instance_has_and_get_ternary = sprintf('[%s ? %s : ()]',
495  
496 $self_aka_attr->_inline_instance_has($p->{iexpr_instance}),
497 470 $self_aka_attr->_inline_instance_get($p->{iexpr_instance}),
498 );
499  
500 return [
501  
502 'OMNITRIGGER: {',
503  
504 'my $_OMNITRIG_slot_state = ' . ($p->{iexpr_slot_state} || "MooseX::OmniTrigger::State->singleton->slot($p->{iexpr_instance}, '$attr_name')") . ";",
505  
506 "my \$_OMNITRIG_omnitrig_is_recursing = \$_OMNITRIG_slot_state->{omnitrig_is_recursing};",
507  
508 "local \$_OMNITRIG_slot_state->{omnitrig_is_recursing} = 1;",
509  
510 'if ($_OMNITRIG_omnitrig_is_recursing) {',
511  
512 470 ▶ @{$p->{icode_to_wrap} || []}, ';',
Condition100%2/2
$p->{'icode_to_wrap'} || []
l!l
368102
MC/DC100%1/1
$p->{'icode_to_wrap'} || []
$p->{'icode_to_wrap'}
Truth table100%2/2
A
A= $p->{'icode_to_wrap'}
Aresult
11
00
513  
514 'next OMNITRIGGER;',
515 '}',
516  
517 #===================================================================================
518 # MOOSE DOESN'T (YET) IMPLEMENT INLINE REBLESSING, SO THERE'S NO NEED TO FUSS WITH
519 # LOOKING FOR SET-FOR-TRANSFER-DURING-FIXUP OPERATIONS LIKE WE DO IN
520 # _fire_omnitrigger.
521  
522 "unless (MooseX::OmniTrigger::State->singleton->instance($p->{iexpr_instance})->{omnitrigs_ready}) {",
523  
524 '$_OMNITRIG_slot_state->{fire_omnitrig_when_ready} = 1;',
525  
526 470 ▶ @{$p->{icode_to_wrap} || []}, ';',
Condition80%4/5
$p->{'icode_to_wrap'} || []
l!l
368102
$p->{'iexpr_oldval'} || $iexpr_instance_has_and_get_ternary
l!l&&r!l&&!r
1742960
MC/DC100%1/1
$p->{'icode_to_wrap'} || []
$p->{'icode_to_wrap'}
MC/DC0%0/2
$p->{'iexpr_oldval'} || $iexpr_instance_has_and_get_ternary
$p->{'iexpr_oldval'} $iexpr_instance_has_and_get_ternary
Truth table100%2/2
A
A= $p->{'icode_to_wrap'}
Aresult
11
00
Truth table66%2/3
A || B
A= $p->{'iexpr_oldval'}B= $iexpr_instance_has_and_get_ternary
ABresult
1X1
011
000
527  
528 'next OMNITRIGGER;',
529 '}',
530  
531 #
532 #===================================================================================
533  
534 'my $_OMNITRIG_oldval = ' . ($p->{iexpr_oldval} || $iexpr_instance_has_and_get_ternary) . ';',
535  
536 470 ▶ @{$p->{icode_to_wrap} || []}, ';',
Condition100%2/2
$p->{'icode_to_wrap'} || []
l!l
368102
MC/DC100%1/1
$p->{'icode_to_wrap'} || []
$p->{'icode_to_wrap'}
Truth table100%2/2
A
A= $p->{'icode_to_wrap'}
Aresult
11
00
537  
538 "my \$_OMNITRIG_newval = $iexpr_instance_has_and_get_ternary;",
539  
540 470 ▶ $self_aka_attr->_inline_weaken_value($p->{iexpr_instance}, '$_OMNITRIG_newval->[0]'),
Condition100%2/2
$p->{'iexpr_slot_state'} || "MooseX::OmniTrigger::State->singleton->slot($p->{'iexpr_instance'}, '${attr_name}')"
l!l
102368
MC/DC100%1/1
$p->{'iexpr_slot_state'} || "MooseX::OmniTrigger::State->singleton->slot($p->{'iexpr_instance'}, '${attr_name}')"
$p->{'iexpr_slot_state'}
Truth table100%2/2
A
A= $p->{'iexpr_slot_state'}
Aresult
11
00
541  
542 "$p->{iexpr_instance}->\$_('$attr_name', \$_OMNITRIG_newval, \$_OMNITRIG_oldval) for \$_EE_OMNITRIG_attrs_omnitrigger{$attr_name};",
543  
544 "delete(\$_OMNITRIG_slot_state->{fire_omnitrig_when_ready});",
545 '}',
546 ];
547 }
548  
549 # WHICH SETTERS/CLEARERS TO WRAP?
550  
551 # WE CAN'T WRAP Instance SETTERS, AS WE HAVE NO GOOD WAY OF KNOWING WHETHER THEY'RE BEING CALLED
552 # FOR SET OR FOR SET-RAW OPS.
553  
554 # IDEALLY, WE WANT TO WRAP "BASIC" SETTERS/CLEARERS -- METHODS IN Moose::Meta::Attribute THAT DO
555 # NOTHING MORE THAN SET/CLEAR THE VALUE THROUGH THE INSTANCE INTERFACE AS DIRECTLY AS POSSIBLE
556 # AND THUS AREN'T LIKELY TO CHANGE. AND WE WANT TO WRAP NO MORE SETTERS/CLEARERS THAN ABSOLUTELY
557 # NECESSARY, WHILE STILL INTERCEPTING EVERY "NORMAL" (AND OMITTING EVERY RAW AND INTERNAL-SPECIAL
558 # -PURPOSE) SET/CLEAR OPERATION.
559  
560 #===============================================================================================
561 # MUTABLE INIT-SETTER: THERE ARE A FEW CHOICES, HERE. IN THE END, ALL ROADS LEAD TO
562 # _set_initial_slot_value, WHICH IS AS CLOSE AS WE CAN GET IN Attribute TO A BASIC INIT-SETTER.
563 # IF THERE'S NO INITIALIZER, IT CALLS Instance::set_slot_value DIRECTLY, WHICH IS NICE; IF THERE
564 # *IS* AN INITIALIZER, IT MAKES THE CALL THROUGH AN INITIALIZER WRITER CALLBACK THAT DOES
565 # COERCION. NO WEAKENING.
566  
567 169 ▶ around _set_initial_slot_value => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
568  
569 169 my ($orig_method, $self_aka_attr, undef, $instance) = (shift, shift, @_);
570  
571 169 ▶ return $self_aka_attr->$orig_method(@_) unless $self_aka_attr->has_omnitrigger;
Branch: 1 branch
BranchTrueFalseTotal
unless $self_aka_attr->has_omnitrigger 24 145 169
572  
573 145 my @args_lexical = @_;
574  
575 $self_aka_attr->_fire_omnitrigger({
576  
577 instance => $instance,
578  
579 145 ▶ sub_to_wrap => sub { $self_aka_attr->$orig_method(@args_lexical) },
Subroutine __ANON__: called CC=1 SCAR=0.0
580 145 });
581  
582 # NO EXPLICIT RETVAL.
583 14 };
584  
585 #
586 #===============================================================================================
587  
588 #===============================================================================================
589 # MUTABLE SETTER: NO CHOICE BUT set_value. IT INCLUDES SEVERAL BEHAVIORS APART FROM SIMPLY
590 # SETTING THE VALUE, WHICH MAKES IT NOT THE MOST ATTRACTIVE HOOK (ALTHOUGH IT DOES DO
591 # WEAKENING). TO PERFORM THE ACTUAL SET OP, IT CALLS SUPER (IN Class::MOP::Attribute), WHICH IS
592 # A BETTER HOOK CANDIDATE, AS IT'S PRETTY MUCH A DIRECT LINE TO THE INSTANCE SETTER -- BUT I
593 # CAN'T THINK OF A GOOD WAY TO HANG A METHOD MODIFIER ON Moose::Meta::Attribute'S *SUPER'S*
594 # set_value WITHOUT CAUSING PROBLEMS. FORTUNATELY, IT LOOKS LIKE set_value IS THE ONLY (MUTABLE
595 # NON-INIT) SETTER IN Attribute, AND IT'S ORGANIZED WITH TRIGGERS IN MIND, ANYWAY, WITH THE
596 # TRIGGER OP BEING CONVENIENTLY THE LAST THING TO HAPPEN. WE CAN WRAP set_value AND FEEL
597 # CAUTIOUSLY OK ABOUT IT.
598  
599 41 ▶ around [qw(set_value clear_value)] => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
600  
601 41 my ($orig_method, $self_aka_attr, $instance) = (shift, shift, @_);
602  
603 41 ▶ return $self_aka_attr->$orig_method(@_) unless $self_aka_attr->has_omnitrigger;
Branch: 1 branch
BranchTrueFalseTotal
unless $self_aka_attr->has_omnitrigger 0 41 41
604  
605 41 my @args_lexical = @_;
606  
607 $self_aka_attr->_fire_omnitrigger({
608  
609 instance => $instance,
610  
611 41 ▶ sub_to_wrap => sub { $self_aka_attr->$orig_method(@args_lexical) },
Subroutine __ANON__: called CC=1 SCAR=0.0
612 41 });
613  
614 # NO EXPLICIT RETVAL.
615 14 };
616  
617 #
618 #===============================================================================================
619  
620 #===============================================================================================
621 # IMMUTABLE SETTER: _inline_instance_set DOESN'T DO WEAKENING, BUT OTHERWISE IT'S EXACTLY WHAT
622 # WE'RE LOOKING FOR, HANDLING BOTH INIT-SETTING AND SETTING.
623  
624 333 ▶ around [qw(_inline_instance_set _inline_instance_clear)] => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
625  
626 333 my ($orig_method, $self_aka_attr, $iexpr_instance) = (shift, shift, @_);
627  
628 333 ▶ return $self_aka_attr->$orig_method(@_) unless $self_aka_attr->has_omnitrigger;
Branch: 1 branch
BranchTrueFalseTotal
unless $self_aka_attr->has_omnitrigger 37 296 333
629  
630 return join("\n", ( # ORIG METHODS RETURN EXPRESSIONS AS STRINGS.
631  
632 'do {',
633  
634 296 ▶ @{$self_aka_attr->_icode_fire_omnitrigger({
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 0 296 296
635  
636 icode_to_wrap => [map(ref($_) ? @$_ : $_, $self_aka_attr->$orig_method(@_))],
637  
638 iexpr_instance => $iexpr_instance,
639 })},
640 '}',
641 ));
642 14 };
643  
644 #
645 #===============================================================================================
646  
647 36 ▶ around _weaken_value => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
648  
649 # WE WRAP _weaken_value (AND _inline_weaken_value, BELOW) AS A BIT OF KLUDGERY TO PREVENT
650 # THE WEAKENING OF ALREADY-WEAK VALUES (WHICH WOULD CAUSE Scalar::Util::weaken TO SQUAWK).
651  
652 36 my ($orig_method, $self_aka_attr, $instance) = (shift, shift, @_);
653  
654 36 ▶ return if $self_aka_attr->associated_class->get_meta_instance->slot_value_is_weak($instance, $self_aka_attr->name);
Branch: 1 branch
BranchTrueFalseTotal
if $self_aka_attr->associated_class->get_meta_instance->slot_value_is_weak($instance, $self_aka_attr->name) 18 18 36
655  
656 18 return $self_aka_attr->$orig_method(@_);
657 14 };
658  
659 776 ▶ around _inline_weaken_value => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
660  
661 776 my ($orig_method, $self_aka_attr, $iexpr_instance) = (shift, shift, @_);
662  
663 #===========================================================================================
664 # THE ORIG METHOD TESTS ref($val) AND $attr->is_weak_ref; SO UNLESS THOSE PASS IT'LL RETURN
665 # NOTHING AND WE CAN EARLY OUT. (STRANGE THAT _weaken_value DOESN'T DO THE SAME?)
666  
667 776 ▶ return unless my @icode_weaken_value = ($self_aka_attr->$orig_method(@_));
Branch: 1 branch
BranchTrueFalseTotal
unless my(@icode_weaken_value) = $self_aka_attr->$orig_method(@_) 662 114 776
668  
669 #
670 #===========================================================================================
671  
672 return ( # ORIG METHOD RETURNS CODE AS LIST.
673  
674 114 'unless (Scalar::Util::isweak(' . $self_aka_attr->associated_class->get_meta_instance->inline_slot_access($iexpr_instance, $self_aka_attr->name) . ')) {',
675  
676 @icode_weaken_value,
677 '}',
678 );
679 14 };
680  
681 # around interpolate_class_and_new => sub {
682  
683 # my ($orig_method, $self_aka_attr) = (shift, shift);
684  
685 # my ($new_attr) = $self_aka_attr->$orig_method(@_);
686  
687 # if ($new_attr->does('Moose::Meta::Attribute::Native::Trait')) {
688  
689 # Moose::Util::ensure_all_roles($new_attr->meta, MooseX::OmniTrigger::MetaRole::Attribute::Native::Trait->meta);
690 # }
691  
692 # return $new_attr;
693 # };
694  
695 0 ▶ *Moose::Meta::Attribute::Custom::Trait::OmniTrigger::register_implementation = sub { __PACKAGE__ };
Subroutine __ANON__: not called CC=1 SCAR=1.2
696 }
697  
698 14 ▶{ package MooseX::OmniTrigger::MetaRole::Instance; use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
699  
700 14 ▶ use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
701  
702 2 ▶ around clone_instance => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
703  
704 2 my ($orig_method, $self_aka_meta_instance, $instance) = (shift, shift, @_);
705  
706 2 my $clone = $self_aka_meta_instance->$orig_method($instance);
707  
708 #===========================================================================================
709 # WOULD HAVE PREFERRED NOT TO INVADE CMOP::Instance FOR THIS, BUT THERE WAS NO PLACE INSIDE
710 # CMOP::Class ITSELF TO SNEAK IN AN OMNITRIG STATE RESET *AFTER* THE BASIC CLONING OF THE
711 # INSTANCE AND *BEFORE* THE SETTING OF INITVALS.
712  
713 2 MooseX::OmniTrigger::State->singleton->reset($clone);
714  
715 #
716 #===========================================================================================
717  
718 2 return $clone;
719 14 };
720 }
721  
722 14 ▶{ package MooseX::OmniTrigger::MetaRole::Method::Accessor::Native::Writer; use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
723  
724 14 ▶ use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
725  
726 72 ▶ around _inline_set_new_value => sub {
Subroutine __ANON__: called CC=5 SCAR=17.2
727  
728 72 my ($orig_method, $self_aka_accessor, $iexpr_instance) = (shift, shift, @_);
729  
730 72 my $attr = $self_aka_accessor->associated_attribute;
731  
732 72 ▶ return $self_aka_accessor->$orig_method(@_) unless $attr->can('has_omnitrigger') && $attr->has_omnitrigger;
Branch: 1 branch
BranchTrueFalseTotal
unless $attr->can("has_omnitrigger") and $attr->has_omnitrigger 0 72 72
Condition33%1/3
$attr->can("has_omnitrigger") and $attr->has_omnitrigger
!ll&&!rl&&r
0072
MC/DC0%0/2
$attr->can("has_omnitrigger") and $attr->has_omnitrigger
$attr->can("has_omnitrigger") $attr->has_omnitrigger
Truth table33%1/3
A and B
A= $attr->can("has_omnitrigger")B= $attr->has_omnitrigger
ABresult
0X0
100
111
733  
734 72 ▶ return join("\n", @{$attr->_icode_fire_omnitrigger({ # ORIG METHOD RETURNS CODE AS STRING.
Branch: 2 branches
BranchTrueFalseTotal
ref $_ ? : 0 80 80
$self_aka_accessor->can('_copy_old_value') ? : 28 44 72
735  
736 icode_to_wrap => [map(ref($_) ? @$_ : $_, $self_aka_accessor->$orig_method(@_))],
737  
738 iexpr_instance => $iexpr_instance,
739  
740 iexpr_oldval => sprintf('[%s ? %s : ()]',
741  
742 $self_aka_accessor->_has_value($iexpr_instance),
743  
744 $self_aka_accessor->can('_copy_old_value')
745 ? $self_aka_accessor->_copy_old_value($self_aka_accessor->_get_value($iexpr_instance))
746 : $self_aka_accessor->_get_value($iexpr_instance) ,
747 ),
748 })});
749 14 };
750 }
751  
752 #===================================================================================================
753 # THIS IS PROMISCUOUS, AS IT WILL AFFECT Moose::Meta::Method::Accessor::Native::Writer FOR ALL
754 # CLASSES, NOT JUST MooseX::OmniTriggerED ONES. IT DOESN'T LOOK LIKE Moose::Exporter CAN HELP OUT,
755 # HERE, BUT MAYBE I'M MISSING SOMETHING. ANYWAY, IT WAS EITHER THIS, WHICH THOUGH PROMISCUOUS IS
756 # DIRECT, OR A BIT OF KLUDGERY INVOLVING WRAPPING MM::Attribute::interpolate_class_and_new AND
757 # MM::Attribute::Native::Trait::_native_accessor_class_for, WHICH I'M NOT SURE WOULD'VE BEEEN ANY
758 # BETTER CONSIDERING THE ANON CLASS CACHING GOING ON THERE. THE GOAL IS TO WRAP _inline_set_new_value.
759  
760 14 for ('Moose::Meta::Method::Accessor::Native::Writer') {
761  
762 14 Class::Load::load_class($_);
763  
764 14 Moose::Util::ensure_all_roles($_, MooseX::OmniTrigger::MetaRole::Method::Accessor::Native::Writer->meta);
765 }
766  
767 #
768 #===================================================================================================
769  
770 # { package MooseX::OmniTrigger::MetaRole::Attribute::Native::Trait;
771 #
772 # use Moose::Role;
773 #
774 # around _native_accessor_class_for => sub {
775 #
776 # my ($orig_method, $self_aka_attr) = (shift, shift);
777 #
778 # my $native_accessor_class = $self_aka_attr->$orig_method(@_);
779 #
780 # Moose::Util::ensure_all_roles($native_accessor_class, MooseX::OmniTrigger::MetaRole::Method::Accessor::Native::Writer->meta);
781 #
782 # $native_accessor_class;
783 # };
784 # }
785  
786 14 1;
787  
788 __END__
↑ Summary