File Coverage

blib/lib/Mite/Attribute.pm.mite.pm
Criterion Covered Total %
statement 736 1085 67.8
branch 514 1088 47.2
condition 247 666 37.0
subroutine 53 64 82.8
pod 0 38 0.0
total 1550 2941 52.7


line stmt bran cond sub pod time code
1             {
2              
3             use strict;
4 79     79   605 use warnings;
  79         191  
  79         3210  
5 79     79   510 no warnings qw( once void );
  79         182  
  79         3041  
6 79     79   428  
  79         191  
  79         10093  
7             our $USES_MITE = "Mite::Class";
8             our $MITE_SHIM = "Mite::Shim";
9             our $MITE_VERSION = "0.011000";
10              
11             # Mite keywords
12             BEGIN {
13             my ( $SHIM, $CALLER ) = ( "Mite::Shim", "Mite::Attribute" );
14 79     79   403 (
15             *after, *around, *before, *extends, *field,
16             *has, *param, *signature_for, *with
17             )
18             = do {
19 79         175  
20             no warnings 'redefine';
21             (
22 79     79   508 sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) },
  79         192  
  79         14908  
23             sub { $SHIM->HANDLE_around( $CALLER, "class", @_ ) },
24 0     0   0 sub { $SHIM->HANDLE_before( $CALLER, "class", @_ ) },
25 0     0   0 sub { },
26 0     0   0 sub { $SHIM->HANDLE_has( $CALLER, field => @_ ) },
27       0     sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) },
28 0     0   0 sub { $SHIM->HANDLE_has( $CALLER, param => @_ ) },
29 2291     2291   2004512 sub { $SHIM->HANDLE_signature_for( $CALLER, "class", @_ ) },
30 0     0   0 sub { $SHIM->HANDLE_with( $CALLER, @_ ) },
31 0     0   0 );
32 0     0   0 }
33 79         11181  
34             # Mite imports
35             BEGIN {
36             require Scalar::Util;
37             *STRICT = \&Mite::Shim::STRICT;
38             *bare = \&Mite::Shim::bare;
39 79     79   531 *blessed = \&Scalar::Util::blessed;
40 79         286 *carp = \&Mite::Shim::carp;
41 79         199 *confess = \&Mite::Shim::confess;
42 79         199 *croak = \&Mite::Shim::croak;
43 79         190 *false = \&Mite::Shim::false;
44 79         170 *guard = \&Mite::Shim::guard;
45 79         237 *lock = \&Mite::Shim::lock;
46 79         174 *ro = \&Mite::Shim::ro;
47 79         210 *rw = \&Mite::Shim::rw;
48 79         196 *rwp = \&Mite::Shim::rwp;
49 79         166 *true = \&Mite::Shim::true;
50 79         157 *unlock = \&Mite::Shim::unlock;
51 79         203 }
52 79         154  
53 79         2176 # Gather metadata for constructor and destructor
54             no strict 'refs';
55             my $class = shift;
56             $class = ref($class) || $class;
57             my $linear_isa = mro::get_linear_isa($class);
58 79     79   432 return {
  79         202  
  79         231631  
59 73     73   230 BUILD => [
60 73   33     556 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
61 73         661 map { "$_\::BUILD" } reverse @$linear_isa
62             ],
63             DEMOLISH => [
64 73 50       174 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  73         940  
  73         494  
65 73         433 map { "$_\::DEMOLISH" } @$linear_isa
66             ],
67             HAS_BUILDARGS => $class->can('BUILDARGS'),
68 73 50       173 HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'),
  73         1868  
  0         0  
69 73         330 };
  73         342  
70             }
71              
72             # Standard Moose/Moo-style constructor
73             my $class = ref( $_[0] ) ? ref(shift) : shift;
74             my $meta = ( $Mite::META{$class} ||= $class->__META__ );
75             my $self = bless {}, $class;
76             my $args =
77             $meta->{HAS_BUILDARGS}
78 173 50   173 0 77332 ? $class->BUILDARGS(@_)
79 173   66     1348 : { ( @_ == 1 ) ? %{ $_[0] } : @_ };
80 173         623 my $no_build = delete $args->{__no_BUILD__};
81              
82             # Attribute _order
83             # has declaration, file lib/Mite/Attribute.pm, line 18
84 173 50       1424 $self->{"_order"} = $self->_build__order;
  0 50       0  
85 173         464  
86             # Attribute definition_context (type: HashRef)
87             # has declaration, file lib/Mite/Attribute.pm, line 20
88             do {
89 173         1184 my $value =
90             exists( $args->{"definition_context"} )
91             ? $args->{"definition_context"}
92             : {};
93 173         416 ( ref($value) eq 'HASH' )
94             or croak "Type check failed in constructor: %s should be %s",
95             "definition_context", "HashRef";
96 173 100       668 $self->{"definition_context"} = $value;
97             };
98 173 50       781  
99             # Attribute class (type: Mite::Package)
100             # has declaration, file lib/Mite/Attribute.pm, line 25
101 173         511 if ( exists $args->{"class"} ) {
102             blessed( $args->{"class"} )
103             && $args->{"class"}->isa("Mite::Package")
104             or croak "Type check failed in constructor: %s should be %s",
105             "class", "Mite::Package";
106 173 100       594 $self->{"class"} = $args->{"class"};
107             }
108 111 50 33     2725 require Scalar::Util && Scalar::Util::weaken( $self->{"class"} )
109             if ref $self->{"class"};
110              
111 111         477 # Attribute _class_for_default (type: Mite::Package)
112             # has declaration, file lib/Mite/Attribute.pm, line 41
113             if ( exists $args->{"_class_for_default"} ) {
114 173 100 33     1596 blessed( $args->{"_class_for_default"} )
115             && $args->{"_class_for_default"}->isa("Mite::Package")
116             or croak "Type check failed in constructor: %s should be %s",
117             "_class_for_default", "Mite::Package";
118 173 100       621 $self->{"_class_for_default"} = $args->{"_class_for_default"};
119             }
120 2 50 33     86 require Scalar::Util
121             && Scalar::Util::weaken( $self->{"_class_for_default"} )
122             if ref $self->{"_class_for_default"};
123 2         14  
124             # Attribute name (type: NonEmptyStr)
125             # has declaration, file lib/Mite/Attribute.pm, line 43
126             croak "Missing key in constructor: name" unless exists $args->{"name"};
127 173 100 33     568 (
128             (
129             do {
130              
131 173 50       836 defined( $args->{"name"} ) and do {
132             ref( \$args->{"name"} ) eq 'SCALAR'
133             or ref( \( my $val = $args->{"name"} ) ) eq 'SCALAR';
134             }
135             )
136             or croak "Type check failed in constructor: %s should be %s", "name",
137 173 50       947 "NonEmptyStr";
138             $self->{"name"} = $args->{"name"};
139 173 50       1566  
140             # Attribute init_arg (type: NonEmptyStr|Undef)
141             # has declaration, file lib/Mite/Attribute.pm, line 52
142 173 50 33     321 if ( exists $args->{"init_arg"} ) {
  173         866  
143             do {
144              
145             (
146 173         580 (
147             (
148             do {
149              
150 173 100       766 defined( $args->{"init_arg"} ) and do {
151 6 50       15 ref( \$args->{"init_arg"} ) eq 'SCALAR'
152             or
153             ref( \( my $val = $args->{"init_arg"} ) )
154             eq 'SCALAR';
155             }
156             }
157             )
158             && do {
159              
160 6 100       41 length( $args->{"init_arg"} ) > 0;
161             }
162             )
163 3 50       36 or
164             );
165             or croak "Type check failed in constructor: %s should be %s",
166             "init_arg", "NonEmptyStr|Undef";
167             $self->{"init_arg"} = $args->{"init_arg"};
168             }
169              
170             # Attribute required (type: Bool)
171 3         35 # has declaration, file lib/Mite/Attribute.pm, line 54
172             do {
173             my $value = exists( $args->{"required"} )
174             ? do {
175 6 100 66     19 my $coerced_value = do {
  3         15  
176             my $to_coerce = $args->{"required"};
177             (
178             (
179             !ref $to_coerce
180 6         23 and (!defined $to_coerce
181             or $to_coerce eq q()
182             or $to_coerce eq '0'
183             or $to_coerce eq '1' )
184             )
185 173         325 ) ? $to_coerce
186             : ( ( !!1 ) )
187 173 100       665 ? scalar( do { local $_ = $to_coerce; !!$_ } )
188 14         33 : $to_coerce;
189 14         52 };
190             (
191             (
192             !ref $coerced_value
193             and (!defined $coerced_value
194             or $coerced_value eq q()
195             or $coerced_value eq '0'
196             or $coerced_value eq '1' )
197             )
198             )
199             ? $coerced_value
200 14 50 33     204 : croak( "Type check failed in constructor: %s should be %s",
  0         0  
  0         0  
201             "required", "Bool" );
202             }
203             : false;
204             $self->{"required"} = $value;
205 14 50 33     228 };
206              
207             # Attribute weak_ref (type: Bool)
208             # has declaration, file lib/Mite/Attribute.pm, line 61
209             do {
210             my $value =
211             exists( $args->{"weak_ref"} ) ? $args->{"weak_ref"} : false;
212             (
213             !ref $value
214             and (!defined $value
215             or $value eq q()
216             or $value eq '0'
217 173         592 or $value eq '1' )
218             )
219             or croak "Type check failed in constructor: %s should be %s",
220             "weak_ref", "Bool";
221             $self->{"weak_ref"} = $value;
222 173         336 };
223              
224 173 100       698 # Attribute is (type: Enum["ro","rw","rwp","lazy","bare","locked"])
225             # has declaration, file lib/Mite/Attribute.pm, line 66
226 173 50 66     1769 do {
      66        
227             my $value = exists( $args->{"is"} ) ? $args->{"is"} : "bare";
228             do {
229              
230             ( defined($value)
231             and !ref($value)
232             and $value =~
233             m{\A(?:(?:bare|l(?:azy|ocked)|r(?:wp?|o)))\z} );
234 173         578 or croak "Type check failed in constructor: %s should be %s",
235             "is", "Enum[\"ro\",\"rw\",\"rwp\",\"lazy\",\"bare\",\"locked\"]";
236             $self->{"is"} = $value;
237             };
238              
239 173         349 # Attribute reader (type: MethodNameTemplate|One|Undef)
240 173 100       795 # has declaration, file lib/Mite/Attribute.pm, line 71
241 173 100       310 if ( exists $args->{"reader"} ) {
242             do {
243              
244 173 50 33     2683 (
245             do {
246              
247             (
248             (
249             (
250             do {
251 172         696  
252             defined( $args->{"reader"} ) and do {
253             ref( \$args->{"reader"} ) eq
254             'SCALAR'
255             or ref(
256 172 100       617 \(
257 10 50       29 my $val = $args->{"reader"}
258             )
259             ) eq 'SCALAR';
260             }
261             }
262             )
263             && (
264             do {
265             local $_ = $args->{"reader"};
266             /\A[^\W0-9]\w*\z/;
267             }
268             )
269             )
270 10 100       99 or (
271             (
272             do {
273              
274             defined( $args->{"reader"} ) and do {
275 8 50       119 ref( \$args->{"reader"} ) eq
276             'SCALAR'
277             or ref(
278             \(
279             my $val = $args->{"reader"}
280             )
281             ) eq 'SCALAR';
282             }
283 8         35 }
284 8         108 )
285             && (
286             do { local $_ = $args->{"reader"}; /\%/ }
287             )
288             )
289             );
290             }
291             or do {
292              
293 10 100       79 ( defined( $args->{"reader"} )
294             and !ref( $args->{"reader"} )
295             and $args->{"reader"} =~ m{\A(?:1)\z} );
296             }
297             or
298 8 50       83 );
299             or croak "Type check failed in constructor: %s should be %s",
300             "reader", "MethodNameTemplate|One|Undef";
301             $self->{"reader"} = $args->{"reader"};
302             }
303              
304             # Attribute writer (type: MethodNameTemplate|One|Undef)
305 10 50 100     32 # has declaration, file lib/Mite/Attribute.pm, line 71
  8   66     26  
  8         102  
306             if ( exists $args->{"writer"} ) {
307             do {
308              
309             (
310             do {
311              
312             (
313             (
314             (
315 5 100 66     100 do {
316              
317             defined( $args->{"writer"} ) and do {
318 10 100 100     21 ref( \$args->{"writer"} ) eq
  2         11  
319             'SCALAR'
320             or ref(
321             \(
322             my $val = $args->{"writer"}
323 10         60 )
324             ) eq 'SCALAR';
325             }
326             }
327             )
328 172 100       613 && (
329 11 50       33 do {
330             local $_ = $args->{"writer"};
331             /\A[^\W0-9]\w*\z/;
332             }
333             )
334             )
335             or (
336             (
337             do {
338              
339             defined( $args->{"writer"} ) and do {
340             ref( \$args->{"writer"} ) eq
341             'SCALAR'
342 11 100       122 or ref(
343             \(
344             my $val = $args->{"writer"}
345             )
346             ) eq 'SCALAR';
347 4 50       69 }
348             }
349             )
350             && (
351             do { local $_ = $args->{"writer"}; /\%/ }
352             )
353             )
354             );
355 4         17 }
356 4         58 or do {
357              
358             ( defined( $args->{"writer"} )
359             and !ref( $args->{"writer"} )
360             and $args->{"writer"} =~ m{\A(?:1)\z} );
361             }
362             or
363             );
364             or croak "Type check failed in constructor: %s should be %s",
365 11 100       101 "writer", "MethodNameTemplate|One|Undef";
366             $self->{"writer"} = $args->{"writer"};
367             }
368              
369             # Attribute accessor (type: MethodNameTemplate|One|Undef)
370 4 50       39 # has declaration, file lib/Mite/Attribute.pm, line 71
371             if ( exists $args->{"accessor"} ) {
372             do {
373              
374             (
375             do {
376              
377 11 50 66     25 (
  4   66     14  
  4         54  
378             (
379             (
380             do {
381              
382             defined( $args->{"accessor"} ) and do {
383             ref( \$args->{"accessor"} ) eq
384             'SCALAR'
385             or ref(
386             \(
387 11 100 66     114 my $val =
388             $args->{"accessor"}
389             )
390 11 100 66     30 ) eq 'SCALAR';
  7         37  
391             }
392             }
393             )
394             && (
395 11         49 do {
396             local $_ = $args->{"accessor"};
397             /\A[^\W0-9]\w*\z/;
398             }
399             )
400 172 100       594 )
401 11 50       32 or (
402             (
403             do {
404              
405             defined( $args->{"accessor"} ) and do {
406             ref( \$args->{"accessor"} ) eq
407             'SCALAR'
408             or ref(
409             \(
410             my $val =
411             $args->{"accessor"}
412             )
413             ) eq 'SCALAR';
414 11 100       117 }
415             }
416             )
417             && (
418             do { local $_ = $args->{"accessor"}; /\%/ }
419             )
420 5 50       72 )
421             );
422             }
423             or do {
424              
425             ( defined( $args->{"accessor"} )
426             and !ref( $args->{"accessor"} )
427             and $args->{"accessor"} =~ m{\A(?:1)\z} );
428 5         21 }
429 5         43 or
430             );
431             or croak "Type check failed in constructor: %s should be %s",
432             "accessor", "MethodNameTemplate|One|Undef";
433             $self->{"accessor"} = $args->{"accessor"};
434             }
435              
436             # Attribute clearer (type: MethodNameTemplate|One|Undef)
437             # has declaration, file lib/Mite/Attribute.pm, line 71
438 11 100       121 if ( exists $args->{"clearer"} ) {
439             do {
440              
441             (
442             do {
443              
444 5 50       63 (
445             (
446             (
447             do {
448              
449             defined( $args->{"clearer"} ) and do {
450             ref( \$args->{"clearer"} ) eq
451 11 50 100     23 'SCALAR'
  5   66     15  
  5         75  
452             or ref(
453             \(
454             my $val = $args->{"clearer"}
455             )
456             ) eq 'SCALAR';
457             }
458             }
459             )
460             && (
461 10 100 66     143 do {
462             local $_ = $args->{"clearer"};
463             /\A[^\W0-9]\w*\z/;
464 11 100 100     25 }
  6         28  
465             )
466             )
467             or (
468             (
469 11         37 do {
470              
471             defined( $args->{"clearer"} ) and do {
472             ref( \$args->{"clearer"} ) eq
473             'SCALAR'
474 172 100       584 or ref(
475 10 50       29 \(
476             my $val = $args->{"clearer"}
477             )
478             ) eq 'SCALAR';
479             }
480             }
481             )
482             && (
483             do { local $_ = $args->{"clearer"}; /\%/ }
484             )
485             )
486             );
487             }
488 10 100       106 or do {
489              
490             ( defined( $args->{"clearer"} )
491             and !ref( $args->{"clearer"} )
492             and $args->{"clearer"} =~ m{\A(?:1)\z} );
493 3 50       42 }
494             or
495             );
496             or croak "Type check failed in constructor: %s should be %s",
497             "clearer", "MethodNameTemplate|One|Undef";
498             $self->{"clearer"} = $args->{"clearer"};
499             }
500              
501 3         13 # Attribute predicate (type: MethodNameTemplate|One|Undef)
502 3         36 # has declaration, file lib/Mite/Attribute.pm, line 71
503             if ( exists $args->{"predicate"} ) {
504             do {
505              
506             (
507             do {
508              
509             (
510             (
511 10 100       152 (
512             do {
513              
514             defined( $args->{"predicate"} ) and do {
515             ref( \$args->{"predicate"} ) eq
516 3 50       25 'SCALAR'
517             or ref(
518             \(
519             my $val =
520             $args->{"predicate"}
521             )
522             ) eq 'SCALAR';
523 10 50 66     17 }
  3   66     8  
  3         40  
524             }
525             )
526             && (
527             do {
528             local $_ = $args->{"predicate"};
529             /\A[^\W0-9]\w*\z/;
530             }
531             )
532             )
533 10 100 66     174 or (
534             (
535             do {
536 10 100 66     24  
  7         46  
537             defined( $args->{"predicate"} ) and do {
538             ref( \$args->{"predicate"} ) eq
539             'SCALAR'
540             or ref(
541 10         37 \(
542             my $val =
543             $args->{"predicate"}
544             )
545             ) eq 'SCALAR';
546 172 100       572 }
547 10 50       18 }
548             )
549             && (
550             do { local $_ = $args->{"predicate"}; /\%/ }
551             )
552             )
553             );
554             }
555             or do {
556              
557             ( defined( $args->{"predicate"} )
558             and !ref( $args->{"predicate"} )
559             and $args->{"predicate"} =~ m{\A(?:1)\z} );
560 10 100       105 }
561             or do {
562              
563             !defined( $args->{"predicate"} );
564             }
565             );
566 4 50       64 or croak "Type check failed in constructor: %s should be %s",
567             "predicate", "MethodNameTemplate|One|Undef";
568             $self->{"predicate"} = $args->{"predicate"};
569             }
570              
571             # Attribute lvalue (type: MethodNameTemplate|One|Undef)
572             # has declaration, file lib/Mite/Attribute.pm, line 71
573             if ( exists $args->{"lvalue"} ) {
574 4         16 do {
575 4         30  
576             (
577             do {
578              
579             (
580             (
581             (
582             do {
583              
584 10 100       103 defined( $args->{"lvalue"} ) and do {
585             ref( \$args->{"lvalue"} ) eq
586             'SCALAR'
587             or ref(
588             \(
589             my $val = $args->{"lvalue"}
590 4 50       42 )
591             ) eq 'SCALAR';
592             }
593             }
594             )
595             && (
596             do {
597 10 50 66     31 local $_ = $args->{"lvalue"};
  4   66     10  
  4         31  
598             /\A[^\W0-9]\w*\z/;
599             }
600             )
601             )
602             or (
603             (
604             do {
605              
606             defined( $args->{"lvalue"} ) and do {
607 10 100 66     118 ref( \$args->{"lvalue"} ) eq
608             'SCALAR'
609 10 100 66     34 or ref(
610             \(
611             my $val = $args->{"lvalue"}
612 6         27 )
613             ) eq 'SCALAR';
614             }
615             }
616             )
617             && (
618 10         37 do { local $_ = $args->{"lvalue"}; /\%/ }
619             )
620             )
621             );
622             }
623 172 100       606 or do {
624 16 50       33  
625             ( defined( $args->{"lvalue"} )
626             and !ref( $args->{"lvalue"} )
627             and $args->{"lvalue"} =~ m{\A(?:1)\z} );
628             }
629             or
630             );
631             or croak "Type check failed in constructor: %s should be %s",
632             "lvalue", "MethodNameTemplate|One|Undef";
633             $self->{"lvalue"} = $args->{"lvalue"};
634             }
635              
636             # Attribute local_writer (type: MethodNameTemplate|One|Undef)
637 16 100       101 # has declaration, file lib/Mite/Attribute.pm, line 71
638             if ( exists $args->{"local_writer"} ) {
639             do {
640              
641             (
642 9 50       77 do {
643              
644             (
645             (
646             (
647             do {
648              
649             defined( $args->{"local_writer"} )
650 9         24 and do {
651 9         77 ref( \$args->{"local_writer"} ) eq
652             'SCALAR'
653             or ref(
654             \(
655             my $val =
656             $args->{"local_writer"}
657             )
658             ) eq 'SCALAR';
659             }
660 16 100       123 }
661             )
662             && (
663             do {
664             local $_ = $args->{"local_writer"};
665 9 50       70 /\A[^\W0-9]\w*\z/;
666             }
667             )
668             )
669             or (
670             (
671             do {
672 16 50 66     32  
  9   66     17  
  9         74  
673             defined( $args->{"local_writer"} )
674             and do {
675             ref( \$args->{"local_writer"} ) eq
676             'SCALAR'
677             or ref(
678             \(
679             my $val =
680             $args->{"local_writer"}
681             )
682 16 100 66     175 ) eq 'SCALAR';
683             }
684             }
685 16 100 66     35 )
  7         43  
686             && (
687             do {
688             local $_ = $args->{"local_writer"};
689             /\%/;
690 16         56 }
691             )
692             )
693             );
694             }
695 172 100       601 or do {
696 8 50       18  
697             ( defined( $args->{"local_writer"} )
698             and !ref( $args->{"local_writer"} )
699             and $args->{"local_writer"} =~ m{\A(?:1)\z} );
700             }
701             or do {
702              
703             !defined( $args->{"local_writer"} );
704             }
705             );
706             or croak "Type check failed in constructor: %s should be %s",
707             "local_writer", "MethodNameTemplate|One|Undef";
708             $self->{"local_writer"} = $args->{"local_writer"};
709             }
710 8 100       83  
711             # Attribute isa (type: Str|Ref)
712             # has declaration, file lib/Mite/Attribute.pm, line 77
713             if ( exists $args->{"isa"} ) {
714             do {
715              
716 2 50       17 (
717             do {
718              
719             defined( $args->{"isa"} ) and do {
720             ref( \$args->{"isa"} ) eq 'SCALAR'
721             or ref( \( my $val = $args->{"isa"} ) ) eq
722             'SCALAR';
723             }
724 2         6 }
725 2         19 );
726             or croak "Type check failed in constructor: %s should be %s",
727             "isa", "Str|Ref";
728             $self->{"isa"} = $args->{"isa"};
729             }
730              
731             # Attribute does (type: Str|Ref)
732             # has declaration, file lib/Mite/Attribute.pm, line 82
733             if ( exists $args->{"does"} ) {
734             do {
735 7 100       73  
736             (
737             do {
738              
739             defined( $args->{"does"} ) and do {
740             ref( \$args->{"does"} ) eq 'SCALAR'
741 1 50       8 or ref( \( my $val = $args->{"does"} ) ) eq
742             'SCALAR';
743             }
744             }
745             );
746             or croak "Type check failed in constructor: %s should be %s",
747             "does", "Str|Ref";
748 8 100 66     15 $self->{"does"} = $args->{"does"};
      100        
749 1         2 }
750 1         16  
751             # Attribute enum (type: ArrayRef[NonEmptyStr])
752             # has declaration, file lib/Mite/Attribute.pm, line 87
753             if ( exists $args->{"enum"} ) {
754             (
755             and do {
756             my $ok = 1;
757             for my $i ( @{ $args->{"enum"} } ) {
758             ( $ok = 0, last )
759             unless (
760             (
761 7 100 66     68 do {
762              
763 8 100 100     19 defined($i) and do {
764             ref( \$i ) eq 'SCALAR'
765             or ref( \( my $val = $i ) ) eq
766 6         32 'SCALAR';
767             }
768             )
769             && ( length($i) > 0 )
770             );
771             };
772 8         24 $ok;
773             }
774             )
775             or croak "Type check failed in constructor: %s should be %s",
776             "enum", "ArrayRef[NonEmptyStr]";
777 172 100       622 $self->{"enum"} = $args->{"enum"};
778 19 50       43 }
779              
780             # Attribute type (type: Object|Undef)
781             # has declaration, file lib/Mite/Attribute.pm, line 92
782             if ( exists $args->{"type"} ) {
783             do {
784              
785 19 50       167 (
786             (
787 19 100       337 do {
788              
789             use Scalar::Util ();
790             Scalar::Util::blessed( $args->{"type"} );
791 19 100       52 }
  2         14  
792             );
793             or croak "Type check failed in constructor: %s should be %s",
794             "type", "Object|Undef";
795             $self->{"type"} = $args->{"type"};
796 19         99 }
797              
798             # Attribute coerce (type: Bool)
799             # has declaration, file lib/Mite/Attribute.pm, line 97
800             do {
801 172 50       575 my $value = exists( $args->{"coerce"} ) ? $args->{"coerce"} : false;
802 0 0       0 (
803             !ref $value
804             and (!defined $value
805             or $value eq q()
806             or $value eq '0'
807             or $value eq '1' )
808             )
809 0 0       0 or croak "Type check failed in constructor: %s should be %s",
810             "coerce", "Bool";
811 0 0       0 $self->{"coerce"} = $value;
812             };
813              
814             # Attribute locked (type: Bool)
815 0 0       0 # has declaration, file lib/Mite/Attribute.pm, line 102
  0         0  
816             do {
817             my $value = exists( $args->{"locked"} ) ? $args->{"locked"} : false;
818             (
819             !ref $value
820 0         0 and (!defined $value
821             or $value eq q()
822             or $value eq '0'
823             or $value eq '1' )
824             )
825 172 100       606 or croak "Type check failed in constructor: %s should be %s",
826             "locked", "Bool";
827 2         12 $self->{"locked"} = $value;
828 2 50 33     4 };
829 2         6  
830 2         4 # Attribute default (type: Undef|Str|CodeRef|ScalarRef|Dict[]|Tuple[])
  2         11  
831             # has declaration, file lib/Mite/Attribute.pm, line 107
832             if ( exists $args->{"default"} ) {
833             do {
834 6 50 33     11  
835             (
836             or do {
837 6 50       16  
838 6 50       55 defined( $args->{"default"} ) and do {
839             ref( \$args->{"default"} ) eq 'SCALAR'
840             or ref( \( my $val = $args->{"default"} ) ) eq
841             'SCALAR';
842             }
843             }
844             or do {
845              
846             ref( $args->{"default"} ) eq 'CODE';
847 2         8 }
848             or do {
849              
850             ref( $args->{"default"} ) eq 'SCALAR'
851             or ref( $args->{"default"} ) eq 'REF';
852 2         9 }
853             or do {
854              
855             do {
856              
857 172 50       589 ref( $args->{"default"} ) eq 'HASH';
858 0 0       0 }
859             and
860             not( grep !/\A(?:)\z/, keys %{ $args->{"default"} } );
861             }
862             or do {
863              
864             do {
865              
866 79     79   718 ref( $args->{"default"} ) eq 'ARRAY';
  79         223  
  79         358440  
867 0         0 }
868             and @{ $args->{"default"} } == 0;
869 0 0       0 }
  0         0  
870             );
871             or croak "Type check failed in constructor: %s should be %s",
872             "default", "Undef|Str|CodeRef|ScalarRef|Dict[]|Tuple[]";
873             $self->{"default"} = $args->{"default"};
874 0         0 }
875              
876             # Attribute default_is_trusted (type: Bool)
877             # has declaration, file lib/Mite/Attribute.pm, line 113
878             do {
879 172         317 my $value = exists( $args->{"default_is_trusted"} )
880 172 100       735 ? do {
881             my $coerced_value = do {
882 172 50 66     1794 my $to_coerce = $args->{"default_is_trusted"};
      66        
883             (
884             (
885             !ref $to_coerce
886             and (!defined $to_coerce
887             or $to_coerce eq q()
888             or $to_coerce eq '0'
889             or $to_coerce eq '1' )
890 172         730 )
891             ) ? $to_coerce
892             : ( ( !!1 ) )
893             ? scalar( do { local $_ = $to_coerce; !!$_ } )
894             : $to_coerce;
895 172         341 };
896 172 100       759 (
897             (
898 172 50 66     1742 !ref $coerced_value
      66        
899             and (!defined $coerced_value
900             or $coerced_value eq q()
901             or $coerced_value eq '0'
902             or $coerced_value eq '1' )
903             )
904             )
905             ? $coerced_value
906 172         746 : croak( "Type check failed in constructor: %s should be %s",
907             "default_is_trusted", "Bool" );
908             }
909             : false;
910             $self->{"default_is_trusted"} = $value;
911 172 100       640 };
912 93 50       168  
913             # Attribute default_does_trigger (type: Bool)
914             # has declaration, file lib/Mite/Attribute.pm, line 113
915             do {
916 93         616 my $value = exists( $args->{"default_does_trigger"} )
917             ? do {
918             my $coerced_value = do {
919             my $to_coerce = $args->{"default_does_trigger"};
920 86 50       398 (
921             (
922 86 100       965 !ref $to_coerce
923             and (!defined $to_coerce
924             or $to_coerce eq q()
925             or $to_coerce eq '0'
926             or $to_coerce eq '1' )
927             )
928             ) ? $to_coerce
929 36         245 : ( ( !!1 ) )
930             ? scalar( do { local $_ = $to_coerce; !!$_ } )
931             : $to_coerce;
932             };
933             (
934             (
935 5 100       59 !ref $coerced_value
936             and (!defined $coerced_value
937             or $coerced_value eq q()
938             or $coerced_value eq '0'
939             or $coerced_value eq '1' )
940             )
941             )
942             ? $coerced_value
943 4         26 : croak( "Type check failed in constructor: %s should be %s",
944             "default_does_trigger", "Bool" );
945             }
946 4 100       13 : false;
  1         8  
947             $self->{"default_does_trigger"} = $value;
948 93 100 100     167 };
      100        
      100        
      100        
949              
950             # Attribute skip_argc_check (type: Bool)
951             # has declaration, file lib/Mite/Attribute.pm, line 113
952             do {
953             my $value = exists( $args->{"skip_argc_check"} )
954 3         18 ? do {
955             my $coerced_value = do {
956 3 50       7 my $to_coerce = $args->{"skip_argc_check"};
  3         26  
957             (
958             (
959             !ref $to_coerce
960             and (!defined $to_coerce
961             or $to_coerce eq q()
962 93         317 or $to_coerce eq '0'
963             or $to_coerce eq '1' )
964             )
965             ) ? $to_coerce
966             : ( ( !!1 ) )
967 172         338 ? scalar( do { local $_ = $to_coerce; !!$_ } )
968             : $to_coerce;
969 172 100       589 };
970 11         29 (
971 11         47 (
972             !ref $coerced_value
973             and (!defined $coerced_value
974             or $coerced_value eq q()
975             or $coerced_value eq '0'
976             or $coerced_value eq '1' )
977             )
978             )
979             ? $coerced_value
980             : croak( "Type check failed in constructor: %s should be %s",
981             "skip_argc_check", "Bool" );
982 11 50 33     241 }
  0         0  
  0         0  
983             : false;
984             $self->{"skip_argc_check"} = $value;
985             };
986              
987 11 50 33     197 # Attribute lazy (type: Bool)
988             # has declaration, file lib/Mite/Attribute.pm, line 120
989             do {
990             my $value = exists( $args->{"lazy"} ) ? $args->{"lazy"} : false;
991             (
992             !ref $value
993             and (!defined $value
994             or $value eq q()
995             or $value eq '0'
996             or $value eq '1' )
997             )
998             or croak "Type check failed in constructor: %s should be %s",
999 172         569 "lazy", "Bool";
1000             $self->{"lazy"} = $value;
1001             };
1002              
1003             # Attribute coderef_default_variable (type: NonEmptyStr)
1004 172         327 # has declaration, file lib/Mite/Attribute.pm, line 132
1005             if ( exists $args->{"coderef_default_variable"} ) {
1006 172 100       634 (
1007 9         22 (
1008 9         24 do {
1009              
1010             defined( $args->{"coderef_default_variable"} ) and do {
1011             ref( \$args->{"coderef_default_variable"} ) eq
1012             'SCALAR'
1013             or ref(
1014             \(
1015             my $val =
1016             $args->{"coderef_default_variable"}
1017             )
1018             ) eq 'SCALAR';
1019 9 50 33     167 }
  0         0  
  0         0  
1020             )
1021             && do {
1022              
1023             length( $args->{"coderef_default_variable"} ) > 0;
1024 9 50 33     126 )
1025             or croak "Type check failed in constructor: %s should be %s",
1026             "coderef_default_variable", "NonEmptyStr";
1027             $self->{"coderef_default_variable"} =
1028             $args->{"coderef_default_variable"};
1029             }
1030              
1031             # Attribute trigger (type: MethodNameTemplate|One|CodeRef)
1032             # has declaration, file lib/Mite/Attribute.pm, line 134
1033             if ( exists $args->{"trigger"} ) {
1034             do {
1035              
1036 172         459 (
1037             do {
1038              
1039             (
1040             (
1041 172         312 (
1042             do {
1043 172 100       640  
1044 7         18 defined( $args->{"trigger"} ) and do {
1045 7         16 ref( \$args->{"trigger"} ) eq
1046             'SCALAR'
1047             or ref(
1048             \(
1049             my $val = $args->{"trigger"}
1050             )
1051             ) eq 'SCALAR';
1052             }
1053             }
1054             )
1055             && (
1056 7 50 33     112 do {
  0         0  
  0         0  
1057             local $_ = $args->{"trigger"};
1058             /\A[^\W0-9]\w*\z/;
1059             }
1060             )
1061 7 50 33     91 )
1062             or (
1063             (
1064             do {
1065              
1066             defined( $args->{"trigger"} ) and do {
1067             ref( \$args->{"trigger"} ) eq
1068             'SCALAR'
1069             or ref(
1070             \(
1071             my $val = $args->{"trigger"}
1072             )
1073 172         479 ) eq 'SCALAR';
1074             }
1075             }
1076             )
1077             && (
1078 172         408 do { local $_ = $args->{"trigger"}; /\%/ }
1079 172 100       674 )
1080             )
1081 172 50 66     1936 );
      66        
1082             }
1083             or do {
1084              
1085             ( defined( $args->{"trigger"} )
1086             and !ref( $args->{"trigger"} )
1087             and $args->{"trigger"} =~ m{\A(?:1)\z} );
1088             }
1089 172         613 or do {
1090              
1091             ref( $args->{"trigger"} ) eq 'CODE';
1092             }
1093             );
1094 172 50       646 or croak "Type check failed in constructor: %s should be %s",
1095             "trigger", "MethodNameTemplate|One|CodeRef";
1096             $self->{"trigger"} = $args->{"trigger"};
1097             }
1098              
1099             # Attribute builder (type: MethodNameTemplate|One|CodeRef)
1100 0 0       0 # has declaration, file lib/Mite/Attribute.pm, line 134
1101             if ( exists $args->{"builder"} ) {
1102             do {
1103              
1104             (
1105             do {
1106 0 0       0  
1107             (
1108             (
1109             (
1110             do {
1111              
1112 0 0 0     0 defined( $args->{"builder"} ) and do {
1113             ref( \$args->{"builder"} ) eq
1114             'SCALAR'
1115 0         0 or ref(
1116             \(
1117             my $val = $args->{"builder"}
1118             )
1119             ) eq 'SCALAR';
1120             }
1121 0         0 }
1122             )
1123             && (
1124             do {
1125             local $_ = $args->{"builder"};
1126 172 100       599 /\A[^\W0-9]\w*\z/;
1127 7 50       12 }
1128             )
1129             )
1130             or (
1131             (
1132             do {
1133              
1134             defined( $args->{"builder"} ) and do {
1135             ref( \$args->{"builder"} ) eq
1136             'SCALAR'
1137             or ref(
1138             \(
1139             my $val = $args->{"builder"}
1140 7 50       56 )
1141             ) eq 'SCALAR';
1142             }
1143             }
1144             )
1145 7 50       74 && (
1146             do { local $_ = $args->{"builder"}; /\%/ }
1147             )
1148             )
1149             );
1150             }
1151             or do {
1152              
1153 7         30 ( defined( $args->{"builder"} )
1154 7         54 and !ref( $args->{"builder"} )
1155             and $args->{"builder"} =~ m{\A(?:1)\z} );
1156             }
1157             or do {
1158              
1159             ref( $args->{"builder"} ) eq 'CODE';
1160             }
1161             );
1162             or croak "Type check failed in constructor: %s should be %s",
1163 7 50       42 "builder", "MethodNameTemplate|One|CodeRef";
1164             $self->{"builder"} = $args->{"builder"};
1165             }
1166              
1167             # Attribute clone (type: MethodNameTemplate|One|CodeRef|Undef)
1168 7 50       61 # has declaration, file lib/Mite/Attribute.pm, line 139
1169             if ( exists $args->{"clone"} ) {
1170             do {
1171              
1172             (
1173             do {
1174              
1175 7 50 33     15 (
  7   33     19  
  7         70  
1176             (
1177             (
1178             do {
1179              
1180             defined( $args->{"clone"} ) and do {
1181             ref( \$args->{"clone"} ) eq 'SCALAR'
1182             or ref(
1183             \( my $val = $args->{"clone"} )
1184             ) eq 'SCALAR';
1185 7 50 33     114 }
1186             }
1187 7 50 33     24 )
1188             && (
1189             do {
1190 0         0 local $_ = $args->{"clone"};
1191             /\A[^\W0-9]\w*\z/;
1192             }
1193             )
1194             )
1195             or (
1196 7         31 (
1197             do {
1198              
1199             defined( $args->{"clone"} ) and do {
1200             ref( \$args->{"clone"} ) eq 'SCALAR'
1201 172 100       574 or ref(
1202 8 50       22 \( my $val = $args->{"clone"} )
1203             ) eq 'SCALAR';
1204             }
1205             }
1206             )
1207             && (
1208             do { local $_ = $args->{"clone"}; /\%/ }
1209             )
1210             )
1211             );
1212             }
1213             or do {
1214              
1215 8 50       91 ( defined( $args->{"clone"} )
1216             and !ref( $args->{"clone"} )
1217             and $args->{"clone"} =~ m{\A(?:1)\z} );
1218             }
1219             or do {
1220 8 100       206  
1221             ref( $args->{"clone"} ) eq 'CODE';
1222             }
1223             );
1224             or croak "Type check failed in constructor: %s should be %s",
1225             "clone", "MethodNameTemplate|One|CodeRef|Undef";
1226             $self->{"clone"} = $args->{"clone"};
1227             }
1228 1         11  
1229 1         16 # Attribute clone_on_read (type: Bool)
1230             # has declaration, file lib/Mite/Attribute.pm, line 148
1231             if ( exists $args->{"clone_on_read"} ) {
1232             do {
1233             my $coerced_value = do {
1234             my $to_coerce = $args->{"clone_on_read"};
1235             (
1236             (
1237             !ref $to_coerce
1238 8 50       61 and (!defined $to_coerce
1239             or $to_coerce eq q()
1240             or $to_coerce eq '0'
1241             or $to_coerce eq '1' )
1242             )
1243 8 100       135 ) ? $to_coerce
1244             : ( ( !!1 ) )
1245             ? scalar( do { local $_ = $to_coerce; !!$_ } )
1246             : $to_coerce;
1247             };
1248             (
1249             !ref $coerced_value
1250 8 50 66     29 and (!defined $coerced_value
  1   66     3  
  1         15  
1251             or $coerced_value eq q()
1252             or $coerced_value eq '0'
1253             or $coerced_value eq '1' )
1254             )
1255             or croak "Type check failed in constructor: %s should be %s",
1256             "clone_on_read", "Bool";
1257             $self->{"clone_on_read"} = $coerced_value;
1258             };
1259             }
1260 8 100 66     125  
1261             # Attribute clone_on_write (type: Bool)
1262 8 100 66     20 # has declaration, file lib/Mite/Attribute.pm, line 148
1263             if ( exists $args->{"clone_on_write"} ) {
1264             do {
1265 7         48 my $coerced_value = do {
1266             my $to_coerce = $args->{"clone_on_write"};
1267             (
1268             (
1269             !ref $to_coerce
1270             and (!defined $to_coerce
1271 8         31 or $to_coerce eq q()
1272             or $to_coerce eq '0'
1273             or $to_coerce eq '1' )
1274             )
1275             ) ? $to_coerce
1276 172 100       575 : ( ( !!1 ) )
1277 7 50       17 ? scalar( do { local $_ = $to_coerce; !!$_ } )
1278             : $to_coerce;
1279             };
1280             (
1281             !ref $coerced_value
1282             and (!defined $coerced_value
1283             or $coerced_value eq q()
1284             or $coerced_value eq '0'
1285             or $coerced_value eq '1' )
1286             )
1287             or croak "Type check failed in constructor: %s should be %s",
1288             "clone_on_write", "Bool";
1289             $self->{"clone_on_write"} = $coerced_value;
1290 7 50       29 };
1291             }
1292              
1293 7 100       53 # Attribute documentation
1294             # has declaration, file lib/Mite/Attribute.pm, line 150
1295             if ( exists $args->{"documentation"} ) {
1296             $self->{"documentation"} = $args->{"documentation"};
1297             }
1298              
1299             # Attribute handles (type: HandlesHash|Enum["1","2"])
1300 6         15 # has declaration, file lib/Mite/Attribute.pm, line 154
1301 6         36 if ( exists $args->{"handles"} ) {
1302             do {
1303             my $coerced_value = do {
1304             my $to_coerce = $args->{"handles"};
1305             (
1306             do {
1307              
1308             (
1309             do {
1310 7 50       25  
1311             ( ref($to_coerce) eq 'HASH' ) and do {
1312             my $ok = 1;
1313 7 100       54 for my $v ( values %{$to_coerce} ) {
1314             ( $ok = 0, last ) unless do {
1315              
1316             (
1317             (
1318             (
1319 7 50 100     12 do {
  6   66     27  
  6         37  
1320              
1321             defined($v)
1322             and do {
1323             ref( \$v )
1324             eq
1325             'SCALAR'
1326             or ref(
1327             \(
1328             my $val
1329 6 100 66     76 = $v
1330             )
1331             ) eq
1332             'SCALAR';
1333             }
1334 1         6 }
1335             )
1336 7 50 100     12 && (
  0   66     0  
1337             do {
1338             local $_ = $v;
1339             /\A[^\W0-9]\w*\z/;
1340             }
1341 7         19 )
1342             )
1343             or ( ref($v) eq 'ARRAY' )
1344             or ( ref($v) eq 'CODE' )
1345             );
1346 172 100       549 }
1347 4         6 };
1348 4         10 for my $k ( keys %{$to_coerce} ) {
1349 4         9 ( $ok = 0, last ) unless do {
1350              
1351             (
1352             (
1353             (
1354             do {
1355              
1356             defined($k)
1357             and do {
1358             ref( \$k )
1359             eq
1360 4 50 33     35 'SCALAR'
  0         0  
  0         0  
1361             or ref(
1362             \(
1363             my $val
1364 4 50 66     27 = $k
      66        
1365             )
1366             ) eq
1367             'SCALAR';
1368             }
1369             }
1370             )
1371             && (
1372 4         9 do {
1373             local $_ = $k;
1374             /\A[^\W0-9]\w*\z/;
1375             }
1376             )
1377             )
1378 172 100       532 or (
1379 4         6 (
1380 4         6 do {
1381 4         6  
1382             defined($k)
1383             and do {
1384             ref( \$k )
1385             eq
1386             'SCALAR'
1387             or ref(
1388             \(
1389             my $val
1390             = $k
1391             )
1392 4 50 33     40 ) eq
  0         0  
  0         0  
1393             'SCALAR';
1394             }
1395             }
1396 4 50 66     37 )
      66        
1397             && (
1398             do {
1399             local $_ = $k;
1400             /\%/;
1401             }
1402             )
1403             )
1404 4         15 );
1405             }
1406             };
1407             $ok;
1408             }
1409             }
1410 172 100       545 or do {
1411 1         2  
1412             ( defined($to_coerce)
1413             and !ref($to_coerce)
1414             and $to_coerce =~ m{\A(?:[12])\z} );
1415             }
1416 172 100       619 );
1417 9         19 )
1418 9         20 ? $to_coerce
1419 9         32 : ( ( ref($to_coerce) eq 'ARRAY' ) ) ? scalar(
1420             do {
1421             local $_ = $to_coerce;
1422             +{ map { $_ => $_ } @$_ };
1423             }
1424             )
1425             : $to_coerce;
1426             };
1427             do {
1428 9 100       62  
1429 5         11 (
1430 5         17 do {
  5         26  
1431 10 50       22  
1432             ( ref($coerced_value) eq 'HASH' ) and do {
1433             my $ok = 1;
1434             for my $v ( values %{$coerced_value} ) {
1435             ( $ok = 0, last ) unless do {
1436              
1437             (
1438             (
1439             (
1440             do {
1441 10 50       44  
1442 10 100       68 defined($v) and do {
1443             ref( \$v ) eq
1444             'SCALAR'
1445             or ref(
1446             \(
1447             my $val =
1448             $v
1449             )
1450             ) eq 'SCALAR';
1451             }
1452             }
1453             )
1454             && (
1455             do {
1456 10 50 66     17 local $_ = $v;
      66        
1457 8         16 /\A[^\W0-9]\w*\z/;
1458 8         85 }
1459             )
1460             )
1461             or ( ref($v) eq 'ARRAY' )
1462             or ( ref($v) eq 'CODE' )
1463             );
1464             }
1465             };
1466             for my $k ( keys %{$coerced_value} ) {
1467 5         15 ( $ok = 0, last ) unless do {
  5         24  
1468 10 50       21  
1469             (
1470             (
1471             (
1472             do {
1473              
1474             defined($k) and do {
1475             ref( \$k ) eq
1476             'SCALAR'
1477             or ref(
1478 10 50       32 \(
1479 10 50       62 my $val =
1480             $k
1481             )
1482             ) eq 'SCALAR';
1483             }
1484             }
1485             )
1486             && (
1487             do {
1488             local $_ = $k;
1489             /\A[^\W0-9]\w*\z/;
1490             }
1491             )
1492             )
1493             or (
1494 10         35 (
1495 10         101 do {
1496              
1497             defined($k) and do {
1498             ref( \$k ) eq
1499             'SCALAR'
1500             or ref(
1501             \(
1502             my $val =
1503             $k
1504             )
1505 4 50       13 ) eq 'SCALAR';
1506 4 50       29 }
1507             }
1508             )
1509             && ( do { local $_ = $k; /\%/ }
1510             )
1511             )
1512             );
1513             }
1514             };
1515             $ok;
1516             }
1517             }
1518             or do {
1519              
1520 10 100 33     17 ( defined($coerced_value)
      66        
1521 4         9 and !ref($coerced_value)
1522 4         22 and $coerced_value =~ m{\A(?:[12])\z} );
1523             }
1524             );
1525             or croak "Type check failed in constructor: %s should be %s",
1526             "handles", "HandlesHash|Enum[\"1\",\"2\"]";
1527             $self->{"handles"} = $coerced_value;
1528             };
1529 5         40 }
1530              
1531             # Attribute handles_via (type: ArrayRef[Str])
1532 9 100       27 # has declaration, file lib/Mite/Attribute.pm, line 160
1533             if ( exists $args->{"handles_via"} ) {
1534             do {
1535 4 100 66     63 my $coerced_value = do {
1536             my $to_coerce = $args->{"handles_via"};
1537             (
1538             do {
1539              
1540             ( ref($to_coerce) eq 'ARRAY' ) and do {
1541             my $ok = 1;
1542             for my $i ( @{$to_coerce} ) {
1543             ( $ok = 0, last ) unless do {
1544 9 50       26  
    100          
1545 2         7 defined($i) and do {
1546 2         6 ref( \$i ) eq 'SCALAR'
  2         12  
1547             or ref( \( my $val = $i ) ) eq
1548             'SCALAR';
1549             }
1550             }
1551 9 50       23 };
1552             $ok;
1553             }
1554             ) ? $to_coerce : (
1555             do {
1556              
1557             defined($to_coerce) and do {
1558 9 100       60 ref( \$to_coerce ) eq 'SCALAR'
1559 7         17 or ref( \( my $val = $to_coerce ) ) eq
1560 7         16 'SCALAR';
  7         26  
1561 12 50       27 }
1562             )
1563             ? scalar( do { local $_ = $to_coerce; [$_] } )
1564             : $to_coerce;
1565             };
1566             do {
1567              
1568             ( ref($coerced_value) eq 'ARRAY' ) and do {
1569             my $ok = 1;
1570 12 50       38 for my $i ( @{$coerced_value} ) {
1571 12 100       142 ( $ok = 0, last ) unless do {
1572              
1573             defined($i) and do {
1574             ref( \$i ) eq 'SCALAR'
1575             or ref( \( my $val = $i ) ) eq 'SCALAR';
1576             }
1577             }
1578             };
1579             $ok;
1580             }
1581             or croak "Type check failed in constructor: %s should be %s",
1582             "handles_via", "ArrayRef[Str]";
1583 12 50 66     19 $self->{"handles_via"} = $coerced_value;
      66        
1584 10         26 };
1585 10         93 }
1586              
1587             # Attribute alias (type: AliasList)
1588             # has declaration, file lib/Mite/Attribute.pm, line 170
1589             do {
1590             my $value =
1591             exists( $args->{"alias"} )
1592             ? $args->{"alias"}
1593             : $Mite::Attribute::__alias_DEFAULT__->($self);
1594 7         23 do {
  7         25  
1595 12 50       21 my $coerced_value = do {
1596             my $to_coerce = $value;
1597             (
1598             do {
1599              
1600             ( ref($to_coerce) eq 'ARRAY' ) and do {
1601             my $ok = 1;
1602             for my $i ( @{$to_coerce} ) {
1603             ( $ok = 0, last ) unless do {
1604 12 50       75  
1605 12 50       79 (
1606             (
1607             (
1608             do {
1609              
1610             defined($i) and do {
1611             ref( \$i ) eq
1612             'SCALAR'
1613             or ref(
1614             \(
1615             my $val =
1616             $i
1617             )
1618 12         26 ) eq 'SCALAR';
1619 12         79 }
1620             }
1621             )
1622             && (
1623             do {
1624             local $_ = $i;
1625             /\A[^\W0-9]\w*\z/;
1626             }
1627             )
1628 4 50       12 )
1629 4 50       20 or (
1630             (
1631             do {
1632              
1633             defined($i) and do {
1634             ref( \$i ) eq
1635             'SCALAR'
1636             or ref(
1637             \(
1638             my $val =
1639             $i
1640 12 100 33     20 )
  4   66     19  
  4         23  
1641             ) eq 'SCALAR';
1642             }
1643             }
1644             )
1645             && ( do { local $_ = $i; /\%/ }
1646 7         63 )
1647             )
1648             );
1649 9 100       24 }
1650             };
1651             $ok;
1652 2 50 33     27 }
1653             ) ? $to_coerce : (
1654             do {
1655              
1656             defined($to_coerce) and do {
1657             ref( \$to_coerce ) eq 'SCALAR'
1658             or ref( \( my $val = $to_coerce ) ) eq
1659             'SCALAR';
1660 9         42 }
1661             ) ? scalar( do { local $_ = $to_coerce; [$_] } )
1662             : ( ( !defined($to_coerce) ) )
1663             ? scalar( do { local $_ = $to_coerce; [] } )
1664             : $to_coerce;
1665             };
1666 172 100       580 do {
1667 3         12  
1668 3         11 ( ref($coerced_value) eq 'ARRAY' ) and do {
1669 3         8 my $ok = 1;
1670             for my $i ( @{$coerced_value} ) {
1671             ( $ok = 0, last ) unless do {
1672              
1673             (
1674 3 50       20 (
1675 0         0 (
1676 0         0 do {
  0         0  
1677 0 0       0  
1678             defined($i) and do {
1679             ref( \$i ) eq 'SCALAR'
1680 0 0       0 or
1681 0 0       0 ref( \( my $val = $i ) )
1682             eq 'SCALAR';
1683             }
1684             }
1685             )
1686             && (
1687 0         0 do {
1688             local $_ = $i;
1689             /\A[^\W0-9]\w*\z/;
1690             }
1691             )
1692             )
1693             or (
1694 3 50       13 (
1695 3 50       20 do {
1696              
1697             defined($i) and do {
1698             ref( \$i ) eq 'SCALAR'
1699             or
1700             ref( \( my $val = $i ) )
1701 3 50       8 eq 'SCALAR';
  3 50       16  
  3         18  
1702             }
1703             }
1704 3 50       7 )
1705             && ( do { local $_ = $i; /\%/ } )
1706             )
1707 3 50       21 );
1708 3         8 }
1709 3         6 };
  3         9  
1710 3 50       6 $ok;
1711             }
1712             or croak "Type check failed in constructor: %s should be %s",
1713 3 50       11 "alias", "AliasList";
1714 3 50       28 $self->{"alias"} = $coerced_value;
1715             };
1716             };
1717              
1718             # Call BUILD methods
1719 3         20 $self->BUILDALL($args) if ( !$no_build and @{ $meta->{BUILD} || [] } );
1720              
1721             # Unrecognized parameters
1722             my @unknown = grep not(
1723             /\A(?:_class_for_default|a(?:ccessor|lias)|builder|c(?:l(?:ass|earer|one(?:_on_(?:read|write))?)|o(?:deref_default_variable|erce))|d(?:ef(?:ault(?:_(?:does_trigger|is_trusted))?|inition_context)|o(?:cumentation|es))|enum|handles(?:_via)?|i(?:nit_arg|sa?)|l(?:azy|oc(?:al_writer|ked)|value)|name|predicate|re(?:ader|quired)|skip_argc_check|t(?:rigger|ype)|w(?:eak_ref|riter))\z/
1724 3         12 ), keys %{$args};
1725             @unknown
1726             and croak(
1727             "Unexpected keys in constructor: " . join( q[, ], sort @unknown ) );
1728              
1729             return $self;
1730 172         368 }
1731              
1732             # Used by constructor to call BUILD methods
1733 172 100       1250 my $class = ref( $_[0] );
1734             my $meta = ( $Mite::META{$class} ||= $class->__META__ );
1735 172         404 $_->(@_) for @{ $meta->{BUILD} || [] };
1736 172         326 }
1737 172         325  
1738             # Destructor should call DEMOLISH methods
1739             my $self = shift;
1740             my $class = ref($self) || $self;
1741             my $meta = ( $Mite::META{$class} ||= $class->__META__ );
1742 172 100       946 my $in_global_destruction =
1743 170         377 defined ${^GLOBAL_PHASE}
1744 170         329 ? ${^GLOBAL_PHASE} eq 'DESTRUCT'
  170         657  
1745 2 50       4 : Devel::GlobalDestruction::in_global_destruction();
1746             for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) {
1747             my $e = do {
1748             local ( $?, $@ );
1749             eval { $demolisher->( $self, $in_global_destruction ) };
1750             $@;
1751             };
1752             no warnings 'misc'; # avoid (in cleanup) warnings
1753             die $e if $e; # rethrow
1754 2 50       16 }
1755 2 50       12 return;
1756             }
1757              
1758             my $__XS = !$ENV{PERL_ONLY}
1759             && eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") };
1760              
1761             # Accessors for _class_for_default
1762             # has declaration, file lib/Mite/Attribute.pm, line 41
1763             @_ > 1
1764             ? do {
1765             blessed( $_[1] ) && $_[1]->isa("Mite::Package")
1766             or croak( "Type check failed in %s: value should be %s",
1767             "accessor", "Mite::Package" );
1768 2         4 $_[0]{"_class_for_default"} = $_[1];
1769 2         14 require Scalar::Util
1770             && Scalar::Util::weaken( $_[0]{"_class_for_default"} )
1771             if ref $_[0]{"_class_for_default"};
1772             $_[0];
1773             }
1774             : do {
1775             (
1776             exists( $_[0]{"_class_for_default"} )
1777             ? $_[0]{"_class_for_default"}
1778 0 0       0 : (
1779 0 0       0 $_[0]{"_class_for_default"} = do {
1780             my $default_value = $_[0]->_build__class_for_default;
1781             blessed($default_value)
1782             && $default_value->isa("Mite::Package")
1783             or croak(
1784             "Type check failed in default: %s should be %s",
1785             "_class_for_default",
1786             "Mite::Package"
1787             );
1788             $default_value;
1789             }
1790 2 50 0     5 )
  0   33     0  
  0         0  
1791             )
1792             }
1793             }
1794              
1795             # Accessors for _order
1796 170         894 # has declaration, file lib/Mite/Attribute.pm, line 18
1797             if ($__XS) {
1798             Class::XSAccessor->import(
1799             chained => 1,
1800             "accessors" => { "_order" => "_order" },
1801             );
1802             }
1803 2 100       9 else {
1804 1 50       7 *_order = sub {
1805             @_ > 1
1806             ? do { $_[0]{"_order"} = $_[1]; $_[0]; }
1807             : ( $_[0]{"_order"} );
1808             };
1809 1         3 }
  1         3  
1810              
1811 172 50       330 # Accessors for accessor
  1 100       3  
  1 100       3  
1812             # has declaration, file lib/Mite/Attribute.pm, line 71
1813             @_ > 1
1814 172 50       339 ? do {
1815             do {
1816              
1817 172 50       883 (
1818 172         349 do {
1819 172         316  
  172         502  
1820 3 50       4 (
1821             (
1822             (
1823             do {
1824              
1825             defined( $_[1] ) and do {
1826             ref( \$_[1] ) eq 'SCALAR'
1827             or ref( \( my $val = $_[1] ) ) eq
1828             'SCALAR';
1829 3 50       14 }
1830 3 50       22 }
1831             )
1832             && (
1833             do { local $_ = $_[1]; /\A[^\W0-9]\w*\z/ }
1834             )
1835             )
1836             or (
1837             (
1838             do {
1839 3         6  
1840 3         19 defined( $_[1] ) and do {
1841             ref( \$_[1] ) eq 'SCALAR'
1842             or ref( \( my $val = $_[1] ) ) eq
1843             'SCALAR';
1844             }
1845             }
1846             )
1847             && (
1848             do { local $_ = $_[1]; /\%/ }
1849 0 0       0 )
1850 0 0       0 )
1851             );
1852             }
1853             or do {
1854              
1855             ( defined( $_[1] )
1856             and !ref( $_[1] )
1857 3 50 0     4 and $_[1] =~ m{\A(?:1)\z} );
  0   33     0  
  0         0  
1858             }
1859             or ( !defined( $_[1] ) )
1860             );
1861             or croak( "Type check failed in %s: value should be %s",
1862 172         663 "accessor", "MethodNameTemplate|One|Undef" );
1863             $_[0]{"accessor"} = $_[1];
1864             $_[0];
1865             }
1866             : do {
1867 172         585 (
1868             exists( $_[0]{"accessor"} ) ? $_[0]{"accessor"} : (
1869             $_[0]{"accessor"} = do {
1870             my $default_value = $_[0]->_build_accessor;
1871             do {
1872 172 50 33     716  
  172 50       1556  
1873             (
1874             do {
1875              
1876             (
1877 164         351 (
  164         2774  
1878             (
1879 164 50       749 do {
1880              
1881             defined($default_value)
1882 164         1202 and do {
1883             ref( \$default_value )
1884             eq 'SCALAR'
1885             or ref(
1886             \(
1887 172     172 0 557 my $val =
1888 172   33     833 $default_value
1889 172 50       340 )
  172         1468  
1890             ) eq 'SCALAR';
1891             }
1892             }
1893             )
1894 49     49   17657 && (
1895 49   33     205 do {
1896 49   33     193 local $_ = $default_value;
1897 49 50       220 /\A[^\W0-9]\w*\z/;
1898             }
1899             )
1900             )
1901 49 50       93 or (
  49         202  
1902 0         0 (
1903 0         0 do {
1904 0         0  
  0         0  
1905 0         0 defined($default_value)
1906             and do {
1907 79     79   765 ref( \$default_value )
  79         230  
  79         746604  
1908 0 0       0 eq 'SCALAR'
1909             or ref(
1910 49         8779 \(
1911             my $val =
1912             $default_value
1913             )
1914             ) eq 'SCALAR';
1915             }
1916             }
1917             )
1918             && (
1919             do {
1920             local $_ = $default_value;
1921 0 0 0     0 /\%/;
1922             }
1923             )
1924 0         0 )
1925             );
1926             }
1927 0 0 0     0 or do {
1928 0         0  
1929             ( defined($default_value)
1930 26 50   26   86 and !ref($default_value)
1931             and $default_value =~ m{\A(?:1)\z} );
1932             }
1933             or ( !defined($default_value) )
1934             );
1935 26 100       128 or croak(
1936 25         132 "Type check failed in default: %s should be %s",
1937 25 50 33     285 "accessor",
1938             "MethodNameTemplate|One|Undef"
1939             );
1940             $default_value;
1941             }
1942             )
1943             )
1944 25         204 }
1945             }
1946              
1947             # Accessors for alias
1948             # has declaration, file lib/Mite/Attribute.pm, line 170
1949             @_ > 1
1950             ? do {
1951             my $value = do {
1952             my $to_coerce = $_[1];
1953             (
1954             do {
1955              
1956             ( ref($to_coerce) eq 'ARRAY' ) and do {
1957             my $ok = 1;
1958             for my $i ( @{$to_coerce} ) {
1959             ( $ok = 0, last ) unless do {
1960              
1961             (
1962             (
1963             (
1964             do {
1965              
1966             defined($i) and do {
1967             ref( \$i ) eq 'SCALAR'
1968             or ref(
1969             \( my $val = $i ) )
1970             eq 'SCALAR';
1971             }
1972 4 50       9 }
1973             )
1974             && (
1975             do {
1976             local $_ = $i;
1977             /\A[^\W0-9]\w*\z/;
1978             }
1979             )
1980             )
1981             or (
1982             (
1983             do {
1984              
1985 4 50       45 defined($i) and do {
1986 4 50       60 ref( \$i ) eq 'SCALAR'
1987             or ref(
1988             \( my $val = $i ) )
1989             eq 'SCALAR';
1990             }
1991             }
1992             )
1993 4         14 && ( do { local $_ = $i; /\%/ } )
  4         66  
1994             )
1995             );
1996             }
1997             };
1998             $ok;
1999             }
2000             ) ? $to_coerce : (
2001 0 0       0 do {
2002 0 0       0  
2003             defined($to_coerce) and do {
2004             ref( \$to_coerce ) eq 'SCALAR'
2005             or ref( \( my $val = $to_coerce ) ) eq 'SCALAR';
2006             }
2007             ) ? scalar( do { local $_ = $to_coerce; [$_] } )
2008             : ( ( !defined($to_coerce) ) )
2009 4 50 0     11 ? scalar( do { local $_ = $to_coerce; [] } )
  0   33     0  
  0         0  
2010             : $to_coerce;
2011             };
2012             do {
2013              
2014 4 0 33     37 ( ref($value) eq 'ARRAY' ) and do {
2015             my $ok = 1;
2016             for my $i ( @{$value} ) {
2017 0 0 0     0 ( $ok = 0, last ) unless do {
2018              
2019             (
2020             (
2021             (
2022             do {
2023              
2024             defined($i) and do {
2025             ref( \$i ) eq 'SCALAR'
2026 4         21 or ref( \( my $val = $i ) )
2027 4         16 eq 'SCALAR';
2028             }
2029 311 100   311 0 957 }
2030             )
2031             && (
2032 307 100       1027 do { local $_ = $i; /\A[^\W0-9]\w*\z/ }
2033 161         681 )
2034 161 50       336 )
2035             or (
2036             (
2037             do {
2038              
2039             defined($i) and do {
2040             ref( \$i ) eq 'SCALAR'
2041             or ref( \( my $val = $i ) )
2042             eq 'SCALAR';
2043             }
2044             }
2045             )
2046             && ( do { local $_ = $i; /\%/ } )
2047             )
2048 161 100       1126 );
2049 63 50       549 }
2050             };
2051             $ok;
2052             }
2053             or croak( "Type check failed in %s: value should be %s",
2054             "accessor", "AliasList" );
2055             $_[0]{"alias"} = $value;
2056             $_[0];
2057             }
2058             : ( $_[0]{"alias"} );
2059             }
2060              
2061             # Accessors for alias_is_for
2062 63         184 # has declaration, file lib/Mite/Attribute.pm, line 172
2063 63         585 @_ == 1 or croak('Reader "alias_is_for" usage: $self->alias_is_for()');
2064             (
2065             exists( $_[0]{"alias_is_for"} )
2066             ? $_[0]{"alias_is_for"}
2067             : ( $_[0]{"alias_is_for"} = $_[0]->_build_alias_is_for ) );
2068             }
2069              
2070             # Accessors for builder
2071             # has declaration, file lib/Mite/Attribute.pm, line 134
2072             if ($__XS) {
2073 161 100       1053 Class::XSAccessor->import(
2074 63 50       415 chained => 1,
2075             "exists_predicates" => { "has_builder" => "builder" },
2076             );
2077             }
2078             else {
2079             *has_builder = sub {
2080             @_ == 1
2081             or croak('Predicate "has_builder" usage: $self->has_builder()');
2082             exists $_[0]{"builder"};
2083             };
2084             }
2085              
2086 161 50 66     9246 @_ > 1
      66        
2087 63         155 ? do {
2088 63         496 do {
2089              
2090             (
2091             do {
2092              
2093             (
2094 161 50 66     327 (
2095             (
2096             do {
2097 98 50 33     859  
2098             defined( $_[1] ) and do {
2099             ref( \$_[1] ) eq 'SCALAR'
2100             or ref( \( my $val = $_[1] ) ) eq
2101             'SCALAR';
2102             }
2103             }
2104             )
2105             && (
2106             do { local $_ = $_[1]; /\A[^\W0-9]\w*\z/ }
2107             )
2108             )
2109 161         756 or (
2110             (
2111             do {
2112              
2113             defined( $_[1] ) and do {
2114             ref( \$_[1] ) eq 'SCALAR'
2115             or ref( \( my $val = $_[1] ) ) eq
2116             'SCALAR';
2117             }
2118             }
2119             )
2120             && (
2121 0         0 do { local $_ = $_[1]; /\%/ }
2122 0         0 )
2123             )
2124             );
2125             }
2126             or do {
2127 0 0       0  
2128 0         0 ( defined( $_[1] )
2129 0         0 and !ref( $_[1] )
  0         0  
2130 0 0       0 and $_[1] =~ m{\A(?:1)\z} );
2131             }
2132             or ( ref( $_[1] ) eq 'CODE' )
2133             );
2134             or croak( "Type check failed in %s: value should be %s",
2135             "accessor", "MethodNameTemplate|One|CodeRef" );
2136             $_[0]{"builder"} = $_[1];
2137             $_[0];
2138             }
2139 0 0       0 : ( $_[0]{"builder"} );
2140 0 0       0 }
2141              
2142             # Accessors for class
2143             # has declaration, file lib/Mite/Attribute.pm, line 25
2144             @_ > 1
2145             ? do {
2146             blessed( $_[1] ) && $_[1]->isa("Mite::Package")
2147             or croak( "Type check failed in %s: value should be %s",
2148             "accessor", "Mite::Package" );
2149 0         0 $_[0]{"class"} = $_[1];
2150 0         0 require Scalar::Util && Scalar::Util::weaken( $_[0]{"class"} )
2151             if ref $_[0]{"class"};
2152             $_[0];
2153             }
2154             : ( $_[0]{"class"} );
2155             }
2156              
2157             # Accessors for clearer
2158             # has declaration, file lib/Mite/Attribute.pm, line 71
2159 0 0       0 @_ > 1
2160 0 0       0 ? do {
2161             do {
2162              
2163             (
2164             do {
2165              
2166             (
2167 0 0 0     0 (
  0   0     0  
  0         0  
2168             (
2169             do {
2170              
2171             defined( $_[1] ) and do {
2172 0         0 ref( \$_[1] ) eq 'SCALAR'
2173             or ref( \( my $val = $_[1] ) ) eq
2174             'SCALAR';
2175             }
2176             }
2177             )
2178             && (
2179 0 0       0 do { local $_ = $_[1]; /\A[^\W0-9]\w*\z/ }
2180 0 0       0 )
2181             )
2182             or (
2183             (
2184 0         0 do {
  0         0  
2185              
2186 0 0       0 defined( $_[1] ) and do {
  0 0       0  
  0 0       0  
2187             ref( \$_[1] ) eq 'SCALAR'
2188             or ref( \( my $val = $_[1] ) ) eq
2189 0 0       0 'SCALAR';
2190             }
2191             }
2192 0 0       0 )
2193 0         0 && (
2194 0         0 do { local $_ = $_[1]; /\%/ }
  0         0  
2195 0 0       0 )
2196             )
2197             );
2198             }
2199             or do {
2200              
2201             ( defined( $_[1] )
2202             and !ref( $_[1] )
2203             and $_[1] =~ m{\A(?:1)\z} );
2204 0 0       0 }
2205 0 0       0 or ( !defined( $_[1] ) )
2206             );
2207             or croak( "Type check failed in %s: value should be %s",
2208             "accessor", "MethodNameTemplate|One|Undef" );
2209             $_[0]{"clearer"} = $_[1];
2210             $_[0];
2211             }
2212 0         0 : do {
  0         0  
2213             (
2214             exists( $_[0]{"clearer"} ) ? $_[0]{"clearer"} : (
2215             $_[0]{"clearer"} = do {
2216             my $default_value = $_[0]->_build_clearer;
2217             do {
2218              
2219             (
2220 0 0       0 do {
2221 0 0       0  
2222             (
2223             (
2224             (
2225             do {
2226              
2227 0 0 0     0 defined($default_value)
  0   0     0  
  0         0  
2228             and do {
2229             ref( \$default_value )
2230             eq 'SCALAR'
2231             or ref(
2232 0         0 \(
2233             my $val =
2234             $default_value
2235             )
2236             ) eq 'SCALAR';
2237 0         0 }
2238 0         0 }
2239             )
2240 496 50   496 0 2917 && (
2241             do {
2242             local $_ = $default_value;
2243             /\A[^\W0-9]\w*\z/;
2244             }
2245             )
2246 119 50   119 0 470 )
2247             or (
2248             (
2249             do {
2250 119 50       695  
2251             defined($default_value)
2252             and do {
2253             ref( \$default_value )
2254             eq 'SCALAR'
2255             or ref(
2256             \(
2257             my $val =
2258             $default_value
2259             )
2260             ) eq 'SCALAR';
2261             }
2262             }
2263             )
2264             && (
2265             do {
2266             local $_ = $default_value;
2267             /\%/;
2268             }
2269             )
2270             )
2271             );
2272 17 50       45 }
2273             or do {
2274              
2275             ( defined($default_value)
2276             and !ref($default_value)
2277             and $default_value =~ m{\A(?:1)\z} );
2278             }
2279             or ( !defined($default_value) )
2280             );
2281             or croak(
2282             "Type check failed in default: %s should be %s",
2283             "clearer",
2284             "MethodNameTemplate|One|Undef"
2285 17 50       111 );
2286 17 50       170 $default_value;
2287             }
2288             )
2289             )
2290             }
2291             }
2292              
2293 17         46 # Accessors for clone
  17         195  
2294             # has declaration, file lib/Mite/Attribute.pm, line 139
2295             if ($__XS) {
2296             Class::XSAccessor->import(
2297             chained => 1,
2298             "getters" => { "cloner_method" => "clone" },
2299             );
2300             }
2301 8 50       60 else {
2302 8 50       70 *cloner_method = sub {
2303             @_ == 1
2304             or croak('Reader "cloner_method" usage: $self->cloner_method()');
2305             $_[0]{"clone"};
2306             };
2307             }
2308              
2309 17 100 33     30 # Accessors for clone_on_read
  8   66     21  
  8         115  
2310             # has declaration, file lib/Mite/Attribute.pm, line 148
2311             @_ == 1
2312             or croak('Reader "clone_on_read" usage: $self->clone_on_read()');
2313             (
2314 17 50 66     34 exists( $_[0]{"clone_on_read"} ) ? $_[0]{"clone_on_read"} : (
2315             $_[0]{"clone_on_read"} = do {
2316             my $default_value = do {
2317 8 50 33     141 my $to_coerce = $_[0]->_build_clone_on_read;
2318             (
2319             (
2320             !ref $to_coerce
2321             and (!defined $to_coerce
2322             or $to_coerce eq q()
2323             or $to_coerce eq '0'
2324             or $to_coerce eq '1' )
2325             )
2326 17         54 ) ? $to_coerce
2327 17         55 : ( ( !!1 ) )
2328             ? scalar( do { local $_ = $to_coerce; !!$_ } )
2329 375 100   375 0 2886 : $to_coerce;
2330             };
2331             (
2332             !ref $default_value
2333             and (!defined $default_value
2334             or $default_value eq q()
2335             or $default_value eq '0'
2336             or $default_value eq '1' )
2337 0 0 0     0 )
2338             or croak( "Type check failed in default: %s should be %s",
2339             "clone_on_read", "Bool" );
2340 0         0 $default_value;
2341             }
2342 0 0 0     0 )
2343 0         0 );
2344             }
2345 162 50   162 0 1375  
2346             # Accessors for clone_on_write
2347             # has declaration, file lib/Mite/Attribute.pm, line 148
2348             @_ == 1
2349             or croak('Reader "clone_on_write" usage: $self->clone_on_write()');
2350             (
2351             exists( $_[0]{"clone_on_write"} ) ? $_[0]{"clone_on_write"} : (
2352             $_[0]{"clone_on_write"} = do {
2353 3 50       7 my $default_value = do {
2354             my $to_coerce = $_[0]->_build_clone_on_write;
2355             (
2356             (
2357             !ref $to_coerce
2358             and (!defined $to_coerce
2359             or $to_coerce eq q()
2360             or $to_coerce eq '0'
2361             or $to_coerce eq '1' )
2362             )
2363             ) ? $to_coerce
2364             : ( ( !!1 ) )
2365             ? scalar( do { local $_ = $to_coerce; !!$_ } )
2366 3 50       30 : $to_coerce;
2367 3 50       84 };
2368             (
2369             !ref $default_value
2370             and (!defined $default_value
2371             or $default_value eq q()
2372             or $default_value eq '0'
2373             or $default_value eq '1' )
2374 3         13 )
  3         44  
2375             or croak( "Type check failed in default: %s should be %s",
2376             "clone_on_write", "Bool" );
2377             $default_value;
2378             }
2379             )
2380             );
2381             }
2382 0 0       0  
2383 0 0       0 # Accessors for coderef_default_variable
2384             # has declaration, file lib/Mite/Attribute.pm, line 132
2385             @_ > 1
2386             ? do {
2387             (
2388             (
2389             do {
2390 3 50 0     9  
  0   33     0  
  0         0  
2391             defined( $_[1] ) and do {
2392             ref( \$_[1] ) eq 'SCALAR'
2393             or ref( \( my $val = $_[1] ) ) eq 'SCALAR';
2394             }
2395 3 0 33     6 )
2396             && ( length( $_[1] ) > 0 )
2397             )
2398 0 0 0     0 or croak(
2399             "Type check failed in %s: value should be %s",
2400             "accessor",
2401             "NonEmptyStr"
2402             );
2403             $_[0]{"coderef_default_variable"} = $_[1];
2404             $_[0];
2405             }
2406             : do {
2407 3         13 (
2408 3         16 exists( $_[0]{"coderef_default_variable"} )
2409             ? $_[0]{"coderef_default_variable"}
2410 297 100   297 0 898 : (
2411             $_[0]{"coderef_default_variable"} = do {
2412             my $default_value =
2413 294 100       929 $Mite::Attribute::__coderef_default_variable_DEFAULT__
2414 162         665 ->( $_[0] );
2415 162 50       343 (
2416             (
2417             do {
2418              
2419             defined($default_value) and do {
2420             ref( \$default_value ) eq 'SCALAR'
2421             or
2422             ref( \( my $val = $default_value ) )
2423             eq 'SCALAR';
2424             }
2425             )
2426             && ( length($default_value) > 0 )
2427             )
2428             or croak(
2429 162 50       3084 "Type check failed in default: %s should be %s",
2430 0 0       0 "coderef_default_variable",
2431             "NonEmptyStr"
2432             );
2433             $default_value;
2434             }
2435             )
2436             )
2437             }
2438             }
2439              
2440             # Accessors for coerce
2441             # has declaration, file lib/Mite/Attribute.pm, line 97
2442             @_ > 1
2443 0         0 ? do {
2444 0         0 (
2445             !ref $_[1]
2446             and (!defined $_[1]
2447             or $_[1] eq q()
2448             or $_[1] eq '0'
2449             or $_[1] eq '1' )
2450             )
2451             or croak( "Type check failed in %s: value should be %s",
2452             "accessor", "Bool" );
2453             $_[0]{"coerce"} = $_[1];
2454 162 50       1290 $_[0];
2455 0 0       0 }
2456             : ( $_[0]{"coerce"} );
2457             }
2458              
2459             # Accessors for compiling_class
2460             # has declaration, file lib/Mite/Attribute.pm, line 30
2461             @_ > 1
2462             ? do {
2463             blessed( $_[1] ) && $_[1]->isa("Mite::Package")
2464             or croak( "Type check failed in %s: value should be %s",
2465             "accessor", "Mite::Package" );
2466             $_[0]{"compiling_class"} = $_[1];
2467 162 50 33     305 $_[0];
      33        
2468 0         0 }
2469 0         0 : ( $_[0]{"compiling_class"} );
2470             }
2471              
2472             defined wantarray
2473             or croak("This method cannot be called in void context");
2474             my $get = "compiling_class";
2475 162 50 33     303 my $set = "compiling_class";
2476             my $has = sub { exists $_[0]{"compiling_class"} };
2477             my $clear = sub { delete $_[0]{"compiling_class"}; $_[0]; };
2478 162 50 33     1588 my $old = undef;
2479             my ( $self, $new ) = @_;
2480             my $restorer = $self->$has
2481             ? do {
2482             $old = $self->$get;
2483             sub { $self->$set($old) }
2484             }
2485             : sub { $self->$clear };
2486             @_ == 2 ? $self->$set($new) : $self->$clear;
2487             &guard( $restorer, $old );
2488             }
2489              
2490 162         638 # Accessors for default
2491             # has declaration, file lib/Mite/Attribute.pm, line 107
2492             if ($__XS) {
2493             Class::XSAccessor->import(
2494             chained => 1,
2495             "exists_predicates" => { "has_default" => "default" },
2496             );
2497             }
2498             else {
2499             *has_default = sub {
2500             @_ == 1
2501             or croak('Predicate "has_default" usage: $self->has_default()');
2502             exists $_[0]{"default"};
2503             };
2504             }
2505              
2506             @_ > 1
2507             ? do {
2508             do {
2509              
2510             (
2511             ( !defined( $_[1] ) ) or do {
2512              
2513             defined( $_[1] ) and do {
2514             ref( \$_[1] ) eq 'SCALAR'
2515             or ref( \( my $val = $_[1] ) ) eq 'SCALAR';
2516 229 50   229 0 805 }
2517             }
2518             or ( ref( $_[1] ) eq 'CODE' )
2519             or ( ref( $_[1] ) eq 'SCALAR' or ref( $_[1] ) eq 'REF' )
2520 229 100       945 or do {
2521 115         300  
2522 115         457 ( ref( $_[1] ) eq 'HASH' )
2523             and not( grep !/\A(?:)\z/, keys %{ $_[1] } );
2524             }
2525             or do {
2526              
2527             ( ref( $_[1] ) eq 'ARRAY' ) and @{ $_[1] } == 0;
2528             }
2529             );
2530             or croak( "Type check failed in %s: value should be %s",
2531             "accessor", "Undef|Str|CodeRef|ScalarRef|Dict[]|Tuple[]" );
2532             $_[0]{"default"} = $_[1];
2533 115 50 33     1733 $_[0];
  0         0  
  0         0  
2534             }
2535             : ( $_[0]{"default"} );
2536             }
2537 115 50 66     1247  
      66        
2538             # Accessors for default_does_trigger
2539             # has declaration, file lib/Mite/Attribute.pm, line 113
2540             @_ > 1
2541             ? do {
2542             my $value = do {
2543             my $to_coerce = $_[1];
2544             (
2545 115         705 (
2546             !ref $to_coerce
2547             and (!defined $to_coerce
2548             or $to_coerce eq q()
2549             or $to_coerce eq '0'
2550             or $to_coerce eq '1' )
2551             )
2552             ) ? $to_coerce
2553             : ( ( !!1 ) ) ? scalar( do { local $_ = $to_coerce; !!$_ } )
2554 295 50   295 0 909 : $to_coerce;
2555             };
2556             (
2557             !ref $value
2558 295 100       1196 and (!defined $value
2559 115         240 or $value eq q()
2560 115         622 or $value eq '0'
2561             or $value eq '1' )
2562             )
2563             or croak( "Type check failed in %s: value should be %s",
2564             "accessor", "Bool" );
2565             $_[0]{"default_does_trigger"} = $value;
2566             $_[0];
2567             }
2568             : ( $_[0]{"default_does_trigger"} );
2569             }
2570              
2571 115 50 33     1927 # Accessors for default_is_trusted
  0         0  
  0         0  
2572             # has declaration, file lib/Mite/Attribute.pm, line 113
2573             @_ > 1
2574             ? do {
2575 115 50 66     1522 my $value = do {
      66        
2576             my $to_coerce = $_[1];
2577             (
2578             (
2579             !ref $to_coerce
2580             and (!defined $to_coerce
2581             or $to_coerce eq q()
2582             or $to_coerce eq '0'
2583 115         735 or $to_coerce eq '1' )
2584             )
2585             ) ? $to_coerce
2586             : ( ( !!1 ) ) ? scalar( do { local $_ = $to_coerce; !!$_ } )
2587             : $to_coerce;
2588             };
2589             (
2590             !ref $value
2591             and (!defined $value
2592             or $value eq q()
2593             or $value eq '0'
2594             or $value eq '1' )
2595             )
2596 0 0 0     0 or croak( "Type check failed in %s: value should be %s",
2597             "accessor", "Bool" );
2598             $_[0]{"default_is_trusted"} = $value;
2599 0 0       0 $_[0];
2600 0 0       0 }
2601             : ( $_[0]{"default_is_trusted"} );
2602             }
2603              
2604             # Accessors for definition_context
2605             # has declaration, file lib/Mite/Attribute.pm, line 20
2606             @_ > 1
2607             ? do {
2608             ( ref( $_[1] ) eq 'HASH' )
2609             or croak( "Type check failed in %s: value should be %s",
2610             "accessor", "HashRef" );
2611             $_[0]{"definition_context"} = $_[1];
2612 0         0 $_[0];
2613 0         0 }
2614             : ( $_[0]{"definition_context"} );
2615 28 50   28 0 2114 }
2616              
2617             # Accessors for documentation
2618             # has declaration, file lib/Mite/Attribute.pm, line 150
2619             if ($__XS) {
2620 28 100       108 Class::XSAccessor->import(
2621 26         117 chained => 1,
2622             "accessors" => { "documentation" => "documentation" },
2623             "exists_predicates" => { "has_documentation" => "documentation" },
2624             );
2625             }
2626 26 50 33     58 else {
2627             *documentation = sub {
2628             @_ > 1
2629 26 50       162 ? do { $_[0]{"documentation"} = $_[1]; $_[0]; }
2630 26 50       271 : ( $_[0]{"documentation"} );
2631             };
2632             *has_documentation = sub {
2633             @_ == 1
2634             or croak(
2635             'Predicate "has_documentation" usage: $self->has_documentation()'
2636             );
2637             exists $_[0]{"documentation"};
2638             };
2639             }
2640              
2641             # Accessors for does
2642             # has declaration, file lib/Mite/Attribute.pm, line 82
2643             if ($__XS) {
2644 26         150 Class::XSAccessor->import(
2645             chained => 1,
2646             "getters" => { "_does" => "does" },
2647             );
2648             }
2649             else {
2650             *_does = sub {
2651             @_ == 1 or croak('Reader "_does" usage: $self->_does()');
2652             $_[0]{"does"};
2653             };
2654             }
2655              
2656             # Accessors for enum
2657 0 0 0     0 # has declaration, file lib/Mite/Attribute.pm, line 87
      0        
2658             if ($__XS) {
2659             Class::XSAccessor->import(
2660             chained => 1,
2661             "exists_predicates" => { "has_enum" => "enum" },
2662             );
2663             }
2664             else {
2665 0         0 *has_enum = sub {
2666 0         0 @_ == 1 or croak('Predicate "has_enum" usage: $self->has_enum()');
2667             exists $_[0]{"enum"};
2668 82 50   82 0 527 };
2669             }
2670              
2671             @_ > 1
2672             ? do {
2673             do {
2674              
2675             ( ref( $_[1] ) eq 'ARRAY' ) and do {
2676 243 50 33     2427 my $ok = 1;
2677             for my $i ( @{ $_[1] } ) {
2678             ( $ok = 0, last )
2679 243         709 unless (
2680 243         529 (
2681             do {
2682 722 100   722 0 3160  
2683             defined($i) and do {
2684             ref( \$i ) eq 'SCALAR'
2685             or ref( \( my $val = $i ) ) eq
2686             'SCALAR';
2687 243 50   243 0 754 }
2688 243         542 }
2689 243         553 )
2690 243     243   1149 && ( length($i) > 0 )
  243         1412  
2691 243     243   954 );
  243         627  
  243         1662  
2692 243         482 };
2693 243         558 $ok;
2694             }
2695             or croak( "Type check failed in %s: value should be %s",
2696 0         0 "accessor", "ArrayRef[NonEmptyStr]" );
2697 0     0   0 $_[0]{"enum"} = $_[1];
2698 0         0 $_[0];
2699 243 50   243   614 }
  243         712  
2700 243 50       1600 : ( $_[0]{"enum"} );
2701 243         928 }
2702              
2703             # Accessors for handles
2704             # has declaration, file lib/Mite/Attribute.pm, line 154
2705             if ($__XS) {
2706             Class::XSAccessor->import(
2707             chained => 1,
2708             "exists_predicates" => { "has_handles" => "handles" },
2709             );
2710             }
2711             else {
2712             *has_handles = sub {
2713             @_ == 1
2714             or croak('Predicate "has_handles" usage: $self->has_handles()');
2715             exists $_[0]{"handles"};
2716             };
2717             }
2718              
2719             @_ > 1
2720             ? do {
2721             my $value = do {
2722             my $to_coerce = $_[1];
2723 5 50       10 (
2724             do {
2725              
2726             (
2727             do {
2728              
2729             ( ref($to_coerce) eq 'HASH' ) and do {
2730 5 50       15 my $ok = 1;
2731 5 50       40 for my $v ( values %{$to_coerce} ) {
2732             ( $ok = 0, last ) unless do {
2733              
2734             (
2735             (
2736             (
2737             do {
2738              
2739             defined($v) and do {
2740             ref( \$v ) eq
2741 0 0       0 'SCALAR'
  0         0  
2742             or ref(
2743 5 0 33     25 \(
      33        
      0        
      33        
      0        
2744             my $val
2745             = $v
2746 0 0       0 )
  0         0  
2747             ) eq 'SCALAR';
2748             }
2749             }
2750             )
2751             && (
2752 5         15 do {
2753 5         15 local $_ = $v;
2754             /\A[^\W0-9]\w*\z/;
2755 386 100   386 0 11451 }
2756             )
2757             )
2758             or ( ref($v) eq 'ARRAY' )
2759             or ( ref($v) eq 'CODE' )
2760             );
2761             }
2762             };
2763 0         0 for my $k ( keys %{$to_coerce} ) {
2764 0         0 ( $ok = 0, last ) unless do {
2765              
2766             (
2767             (
2768             (
2769             do {
2770              
2771             defined($k) and do {
2772             ref( \$k ) eq
2773             'SCALAR'
2774 0 0 0     0 or ref(
  0         0  
  0         0  
2775             \(
2776             my $val
2777             = $k
2778 0 0 0     0 )
      0        
2779             ) eq 'SCALAR';
2780             }
2781             }
2782             )
2783             && (
2784             do {
2785             local $_ = $k;
2786 0         0 /\A[^\W0-9]\w*\z/;
2787 0         0 }
2788             )
2789 81 50   81 0 637 )
2790             or (
2791             (
2792             do {
2793              
2794             defined($k) and do {
2795             ref( \$k ) eq
2796             'SCALAR'
2797 0         0 or ref(
2798 0         0 \(
2799             my $val
2800             = $k
2801             )
2802             ) eq 'SCALAR';
2803             }
2804             }
2805             )
2806             && (
2807             do {
2808 0 0 0     0 local $_ = $k;
  0         0  
  0         0  
2809             /\%/;
2810             }
2811             )
2812 0 0 0     0 )
      0        
2813             );
2814             }
2815             };
2816             $ok;
2817             }
2818             }
2819             or do {
2820 0         0  
2821 0         0 ( defined($to_coerce)
2822             and !ref($to_coerce)
2823 81 50   81 0 711 and $to_coerce =~ m{\A(?:[12])\z} );
2824             }
2825             );
2826             ) ? $to_coerce : ( ( ref($to_coerce) eq 'ARRAY' ) ) ? scalar(
2827             do {
2828             local $_ = $to_coerce;
2829             +{ map { $_ => $_ } @$_ };
2830             }
2831 0 0       0 )
2832             : $to_coerce;
2833             };
2834 0         0 do {
2835 0         0  
2836             (
2837 252 50   252 0 2562 do {
2838              
2839             ( ref($value) eq 'HASH' ) and do {
2840             my $ok = 1;
2841             for my $v ( values %{$value} ) {
2842             ( $ok = 0, last ) unless do {
2843              
2844             (
2845             (
2846             (
2847             do {
2848              
2849             defined($v) and do {
2850             ref( \$v ) eq 'SCALAR'
2851             or ref(
2852             \( my $val = $v ) )
2853             eq 'SCALAR';
2854             }
2855             }
2856             )
2857             && (
2858             do {
2859             local $_ = $v;
2860             /\A[^\W0-9]\w*\z/;
2861             }
2862             )
2863             )
2864             or ( ref($v) eq 'ARRAY' )
2865             or ( ref($v) eq 'CODE' )
2866             );
2867             }
2868             };
2869             for my $k ( keys %{$value} ) {
2870             ( $ok = 0, last ) unless do {
2871              
2872             (
2873             (
2874             (
2875             do {
2876              
2877             defined($k) and do {
2878             ref( \$k ) eq 'SCALAR'
2879             or ref(
2880             \( my $val = $k ) )
2881             eq 'SCALAR';
2882             }
2883             }
2884             )
2885             && (
2886             do {
2887             local $_ = $k;
2888             /\A[^\W0-9]\w*\z/;
2889             }
2890             )
2891             )
2892             or (
2893             (
2894             do {
2895              
2896             defined($k) and do {
2897 0 0       0 ref( \$k ) eq 'SCALAR'
2898             or ref(
2899             \( my $val = $k ) )
2900 0 0       0 eq 'SCALAR';
2901 0         0 }
2902 0         0 }
  0         0  
2903             )
2904             && ( do { local $_ = $k; /\%/ } )
2905             )
2906 0 0 0     0 );
2907             }
2908             };
2909 0 0       0 $ok;
2910 0 0       0 }
2911             }
2912             or do {
2913              
2914             ( defined($value)
2915             and !ref($value)
2916             and $value =~ m{\A(?:[12])\z} );
2917             }
2918             );
2919 0         0 or croak( "Type check failed in %s: value should be %s",
2920             "accessor", "HandlesHash|Enum[\"1\",\"2\"]" );
2921             $_[0]{"handles"} = $value;
2922             $_[0];
2923             }
2924 0         0 : ( $_[0]{"handles"} );
2925 0         0 }
2926              
2927 4 50   4 0 27 # Accessors for handles_via
2928             # has declaration, file lib/Mite/Attribute.pm, line 160
2929             if ($__XS) {
2930             Class::XSAccessor->import(
2931             chained => 1,
2932             "exists_predicates" => { "has_handles_via" => "handles_via" },
2933             );
2934             }
2935             else {
2936             *has_handles_via = sub {
2937             @_ == 1
2938             or croak(
2939             'Predicate "has_handles_via" usage: $self->has_handles_via()');
2940             exists $_[0]{"handles_via"};
2941             };
2942             }
2943              
2944             @_ > 1
2945             ? do {
2946             my $value = do {
2947             my $to_coerce = $_[1];
2948             (
2949 0         0 do {
2950 0         0  
2951             ( ref($to_coerce) eq 'ARRAY' ) and do {
2952             my $ok = 1;
2953             for my $i ( @{$to_coerce} ) {
2954             ( $ok = 0, last ) unless do {
2955              
2956             defined($i) and do {
2957             ref( \$i ) eq 'SCALAR'
2958             or ref( \( my $val = $i ) ) eq
2959 0 0       0 'SCALAR';
2960 0         0 }
2961 0         0 }
  0         0  
2962 0 0       0 };
2963             $ok;
2964             }
2965             ) ? $to_coerce : (
2966             do {
2967              
2968             defined($to_coerce) and do {
2969             ref( \$to_coerce ) eq 'SCALAR'
2970             or ref( \( my $val = $to_coerce ) ) eq 'SCALAR';
2971 0 0       0 }
2972 0 0       0 ) ? scalar( do { local $_ = $to_coerce; [$_] } ) : $to_coerce;
2973             };
2974             do {
2975              
2976             ( ref($value) eq 'ARRAY' ) and do {
2977             my $ok = 1;
2978             for my $i ( @{$value} ) {
2979             ( $ok = 0, last ) unless do {
2980              
2981             defined($i) and do {
2982             ref( \$i ) eq 'SCALAR'
2983             or ref( \( my $val = $i ) ) eq 'SCALAR';
2984 0 0 0     0 }
      0        
2985 0         0 }
2986 0         0 };
2987             $ok;
2988             }
2989             or croak( "Type check failed in %s: value should be %s",
2990             "accessor", "ArrayRef[Str]" );
2991             $_[0]{"handles_via"} = $value;
2992             $_[0];
2993             }
2994             : ( $_[0]{"handles_via"} );
2995 0         0 }
  0         0  
2996 0 0       0  
2997             # Accessors for init_arg
2998             # has declaration, file lib/Mite/Attribute.pm, line 52
2999             @_ > 1
3000             ? do {
3001             do {
3002              
3003             (
3004             (
3005 0 0       0 (
3006 0 0       0 do {
3007              
3008             defined( $_[1] ) and do {
3009             ref( \$_[1] ) eq 'SCALAR'
3010             or ref( \( my $val = $_[1] ) ) eq 'SCALAR';
3011             }
3012             }
3013             )
3014             && ( length( $_[1] ) > 0 )
3015             )
3016             or ( !defined( $_[1] ) )
3017             );
3018             or croak( "Type check failed in %s: value should be %s",
3019 0         0 "accessor", "NonEmptyStr|Undef" );
3020 0         0 $_[0]{"init_arg"} = $_[1];
3021             $_[0];
3022             }
3023             : do {
3024             (
3025             exists( $_[0]{"init_arg"} ) ? $_[0]{"init_arg"} : (
3026             $_[0]{"init_arg"} = do {
3027             my $default_value =
3028             $Mite::Attribute::__init_arg_DEFAULT__->(
3029 0 0       0 $_[0] );
3030 0 0       0 do {
3031              
3032             (
3033             (
3034             (
3035             do {
3036              
3037             defined($default_value) and do {
3038             ref( \$default_value ) eq
3039             'SCALAR'
3040             or ref(
3041             \(
3042 0 0 0     0 my $val =
      0        
3043 0         0 $default_value
3044 0         0 )
3045             ) eq 'SCALAR';
3046             }
3047             }
3048             )
3049             && ( length($default_value) > 0 )
3050             )
3051 0         0 or ( !defined($default_value) )
3052             );
3053             or croak(
3054 0 0       0 "Type check failed in default: %s should be %s",
3055             "init_arg", "NonEmptyStr|Undef" );
3056             $default_value;
3057 0 0 0     0 }
3058             )
3059             )
3060             }
3061             }
3062              
3063             # Accessors for is
3064 0 0       0 # has declaration, file lib/Mite/Attribute.pm, line 66
    0          
3065 0         0 @_ > 1
3066 0         0 ? do {
  0         0  
3067             do {
3068              
3069             ( defined( $_[1] )
3070             and !ref( $_[1] )
3071 0 0       0 and $_[1] =~
3072             m{\A(?:(?:bare|l(?:azy|ocked)|r(?:wp?|o)))\z} );
3073             or croak(
3074             "Type check failed in %s: value should be %s",
3075             "accessor",
3076             "Enum[\"ro\",\"rw\",\"rwp\",\"lazy\",\"bare\",\"locked\"]"
3077             );
3078 0 0       0 $_[0]{"is"} = $_[1];
3079 0         0 $_[0];
3080 0         0 }
  0         0  
3081 0 0       0 : ( $_[0]{"is"} );
3082             }
3083              
3084             # Accessors for isa
3085             # has declaration, file lib/Mite/Attribute.pm, line 77
3086             if ($__XS) {
3087             Class::XSAccessor->import(
3088             chained => 1,
3089             "getters" => { "_isa" => "isa" },
3090 0 0       0 );
3091 0 0       0 }
3092             else {
3093             *_isa = sub {
3094             @_ == 1 or croak('Reader "_isa" usage: $self->_isa()');
3095             $_[0]{"isa"};
3096             };
3097             }
3098              
3099 0 0 0     0 # Accessors for lazy
      0        
3100 0         0 # has declaration, file lib/Mite/Attribute.pm, line 120
3101 0         0 @_ > 1
3102             ? do {
3103             (
3104             !ref $_[1]
3105             and (!defined $_[1]
3106             or $_[1] eq q()
3107             or $_[1] eq '0'
3108             or $_[1] eq '1' )
3109             )
3110 0         0 or croak( "Type check failed in %s: value should be %s",
  0         0  
3111 0 0       0 "accessor", "Bool" );
3112             $_[0]{"lazy"} = $_[1];
3113             $_[0];
3114             }
3115             : ( $_[0]{"lazy"} );
3116             }
3117              
3118             # Accessors for local_writer
3119             # has declaration, file lib/Mite/Attribute.pm, line 71
3120 0 0       0 @_ > 1
3121 0 0       0 ? do {
3122             do {
3123              
3124             (
3125             do {
3126              
3127             (
3128             (
3129             (
3130 0         0 do {
3131 0         0  
3132             defined( $_[1] ) and do {
3133             ref( \$_[1] ) eq 'SCALAR'
3134             or ref( \( my $val = $_[1] ) ) eq
3135             'SCALAR';
3136             }
3137             }
3138             )
3139             && (
3140 0 0       0 do { local $_ = $_[1]; /\A[^\W0-9]\w*\z/ }
3141 0 0       0 )
3142             )
3143             or (
3144             (
3145             do {
3146              
3147             defined( $_[1] ) and do {
3148 0 0 0     0 ref( \$_[1] ) eq 'SCALAR'
  0   0     0  
  0         0  
3149             or ref( \( my $val = $_[1] ) ) eq
3150             'SCALAR';
3151             }
3152             }
3153 0         0 )
3154             && (
3155             do { local $_ = $_[1]; /\%/ }
3156 0 0       0 )
3157             )
3158             );
3159 0 0 0     0 }
3160             or do {
3161              
3162             ( defined( $_[1] )
3163             and !ref( $_[1] )
3164             and $_[1] =~ m{\A(?:1)\z} );
3165             }
3166             or ( !defined( $_[1] ) )
3167 0         0 );
3168 0         0 or croak( "Type check failed in %s: value should be %s",
3169             "accessor", "MethodNameTemplate|One|Undef" );
3170 24 50   24 0 273 $_[0]{"local_writer"} = $_[1];
3171             $_[0];
3172             }
3173             : do {
3174             (
3175             exists( $_[0]{"local_writer"} ) ? $_[0]{"local_writer"} : (
3176             $_[0]{"local_writer"} = do {
3177             my $default_value = $_[0]->_build_local_writer;
3178             do {
3179              
3180             (
3181             do {
3182              
3183             (
3184             (
3185             (
3186             do {
3187              
3188             defined($default_value)
3189             and do {
3190             ref( \$default_value )
3191             eq 'SCALAR'
3192             or ref(
3193 0         0 \(
3194 0         0 my $val =
3195             $default_value
3196             )
3197             ) eq 'SCALAR';
3198             }
3199 0 0       0 }
3200 0         0 )
3201 0         0 && (
  0         0  
3202 0 0       0 do {
3203             local $_ = $default_value;
3204             /\A[^\W0-9]\w*\z/;
3205 0 0       0 }
3206 0 0       0 )
3207             )
3208             or (
3209             (
3210             do {
3211              
3212 0         0 defined($default_value)
3213             and do {
3214             ref( \$default_value )
3215             eq 'SCALAR'
3216             or ref(
3217             \(
3218             my $val =
3219 0 0       0 $default_value
3220 0 0       0 )
3221             ) eq 'SCALAR';
3222             }
3223             }
3224 0 0       0 )
  0 0       0  
  0         0  
3225             && (
3226 0 0       0 do {
3227             local $_ = $default_value;
3228             /\%/;
3229 0 0       0 }
3230 0         0 )
3231 0         0 )
  0         0  
3232 0 0       0 );
3233             }
3234             or do {
3235 0 0       0  
3236 0 0       0 ( defined($default_value)
3237             and !ref($default_value)
3238             and $default_value =~ m{\A(?:1)\z} );
3239             }
3240             or ( !defined($default_value) )
3241 0         0 );
3242             or croak(
3243             "Type check failed in default: %s should be %s",
3244             "local_writer",
3245             "MethodNameTemplate|One|Undef"
3246 0         0 );
3247 0         0 $default_value;
3248             }
3249 4 50   4 0 34 )
3250             )
3251             }
3252             }
3253              
3254             # Accessors for locked
3255             # has declaration, file lib/Mite/Attribute.pm, line 102
3256             @_ > 1
3257 0 0       0 ? do {
3258             (
3259             !ref $_[1]
3260             and (!defined $_[1]
3261             or $_[1] eq q()
3262             or $_[1] eq '0'
3263 0 0 0     0 or $_[1] eq '1' )
3264             )
3265             or croak( "Type check failed in %s: value should be %s",
3266 0 0       0 "accessor", "Bool" );
3267 0 0       0 $_[0]{"locked"} = $_[1];
3268             $_[0];
3269             }
3270             : ( $_[0]{"locked"} );
3271             }
3272              
3273             # Accessors for lvalue
3274             # has declaration, file lib/Mite/Attribute.pm, line 71
3275             @_ > 1
3276             ? do {
3277             do {
3278              
3279 0         0 (
3280 0         0 do {
3281              
3282 532 50   532 0 1272 (
3283             (
3284             (
3285 532 100       1880 do {
3286 107         512  
3287             defined( $_[1] ) and do {
3288             ref( \$_[1] ) eq 'SCALAR'
3289 107 50       246 or ref( \( my $val = $_[1] ) ) eq
3290             'SCALAR';
3291             }
3292             }
3293             )
3294             && (
3295 107 50 33     240 do { local $_ = $_[1]; /\A[^\W0-9]\w*\z/ }
3296             )
3297             )
3298 107 50       565 or (
3299 107 50       1373 (
3300             do {
3301              
3302             defined( $_[1] ) and do {
3303             ref( \$_[1] ) eq 'SCALAR'
3304             or ref( \( my $val = $_[1] ) ) eq
3305             'SCALAR';
3306             }
3307             }
3308             )
3309             && (
3310             do { local $_ = $_[1]; /\%/ }
3311             )
3312             )
3313             );
3314             }
3315             or do {
3316              
3317             ( defined( $_[1] )
3318 107         704 and !ref( $_[1] )
3319             and $_[1] =~ m{\A(?:1)\z} );
3320             }
3321             or ( !defined( $_[1] ) )
3322             );
3323             or croak( "Type check failed in %s: value should be %s",
3324             "accessor", "MethodNameTemplate|One|Undef" );
3325             $_[0]{"lvalue"} = $_[1];
3326             $_[0];
3327             }
3328             : do {
3329             (
3330 4 50       7 exists( $_[0]{"lvalue"} ) ? $_[0]{"lvalue"} : (
3331             $_[0]{"lvalue"} = do {
3332             my $default_value = $_[0]->_build_lvalue;
3333 4 50 33     81 do {
3334              
3335             (
3336             do {
3337              
3338             (
3339             (
3340             (
3341             do {
3342              
3343 4         16 defined($default_value)
3344 4         10 and do {
3345             ref( \$default_value )
3346 946 100   946 0 7092 eq 'SCALAR'
3347             or ref(
3348             \(
3349             my $val =
3350             $default_value
3351             )
3352             ) eq 'SCALAR';
3353             }
3354             }
3355             )
3356             && (
3357             do {
3358             local $_ = $default_value;
3359             /\A[^\W0-9]\w*\z/;
3360             }
3361             )
3362             )
3363             or (
3364             (
3365             do {
3366              
3367             defined($default_value)
3368             and do {
3369             ref( \$default_value )
3370 4 50 33     109 eq 'SCALAR'
      33        
3371             or ref(
3372             \(
3373             my $val =
3374             $default_value
3375             )
3376             ) eq 'SCALAR';
3377             }
3378 4         25 }
3379 4         15 )
3380             && (
3381 339 100   339 0 2099 do {
3382             local $_ = $default_value;
3383             /\%/;
3384             }
3385             )
3386             )
3387             );
3388             }
3389 1 50       8 or do {
3390              
3391             ( defined($default_value)
3392             and !ref($default_value)
3393             and $default_value =~ m{\A(?:1)\z} );
3394             }
3395             or ( !defined($default_value) )
3396             );
3397             or croak(
3398             "Type check failed in default: %s should be %s",
3399             "lvalue",
3400             "MethodNameTemplate|One|Undef"
3401             );
3402 1 50       7 $default_value;
3403 1 50       9 }
3404             )
3405             )
3406             }
3407             }
3408              
3409             # Accessors for name
3410 1         2 # has declaration, file lib/Mite/Attribute.pm, line 43
  1         13  
3411             @_ > 1
3412             ? do {
3413             (
3414             (
3415             do {
3416              
3417             defined( $_[1] ) and do {
3418 0 0       0 ref( \$_[1] ) eq 'SCALAR'
3419 0 0       0 or ref( \( my $val = $_[1] ) ) eq 'SCALAR';
3420             }
3421             )
3422             && ( length( $_[1] ) > 0 )
3423             )
3424             or croak(
3425             "Type check failed in %s: value should be %s",
3426 1 50 0     1 "accessor",
  0   33     0  
  0         0  
3427             "NonEmptyStr"
3428             );
3429             $_[0]{"name"} = $_[1];
3430             $_[0];
3431 1 0 33     4 }
3432             : ( $_[0]{"name"} );
3433             }
3434 0 0 0     0  
3435             # Accessors for predicate
3436             # has declaration, file lib/Mite/Attribute.pm, line 71
3437             @_ > 1
3438             ? do {
3439             do {
3440              
3441             (
3442             do {
3443 1         3  
3444 1         4 (
3445             (
3446 293 100   293 0 942 (
3447             do {
3448              
3449 292 100       874 defined( $_[1] ) and do {
3450 164         652 ref( \$_[1] ) eq 'SCALAR'
3451 164 50       319 or ref( \( my $val = $_[1] ) ) eq
3452             'SCALAR';
3453             }
3454             }
3455             )
3456             && (
3457             do { local $_ = $_[1]; /\A[^\W0-9]\w*\z/ }
3458             )
3459             )
3460             or (
3461             (
3462             do {
3463              
3464             defined( $_[1] ) and do {
3465 164 50       1311 ref( \$_[1] ) eq 'SCALAR'
3466 0 0       0 or ref( \( my $val = $_[1] ) ) eq
3467             'SCALAR';
3468             }
3469             }
3470             )
3471             && (
3472             do { local $_ = $_[1]; /\%/ }
3473             )
3474             )
3475             );
3476             }
3477             or do {
3478              
3479 0         0 ( defined( $_[1] )
3480 0         0 and !ref( $_[1] )
3481             and $_[1] =~ m{\A(?:1)\z} );
3482             }
3483             or ( !defined( $_[1] ) )
3484             );
3485             or croak( "Type check failed in %s: value should be %s",
3486             "accessor", "MethodNameTemplate|One|Undef" );
3487             $_[0]{"predicate"} = $_[1];
3488             $_[0];
3489             }
3490 164 50       1293 : do {
3491 0 0       0 (
3492             exists( $_[0]{"predicate"} ) ? $_[0]{"predicate"} : (
3493             $_[0]{"predicate"} = do {
3494             my $default_value = $_[0]->_build_predicate;
3495             do {
3496              
3497             (
3498             do {
3499              
3500             (
3501             (
3502             (
3503 164 50 33     286 do {
      33        
3504 0         0  
3505 0         0 defined($default_value)
3506             and do {
3507             ref( \$default_value )
3508             eq 'SCALAR'
3509             or ref(
3510             \(
3511 164 50 33     276 my $val =
3512             $default_value
3513             )
3514 164 50 33     1327 ) eq 'SCALAR';
3515             }
3516             }
3517             )
3518             && (
3519             do {
3520             local $_ = $default_value;
3521             /\A[^\W0-9]\w*\z/;
3522             }
3523             )
3524             )
3525             or (
3526 164         771 (
3527             do {
3528              
3529             defined($default_value)
3530             and do {
3531             ref( \$default_value )
3532             eq 'SCALAR'
3533             or ref(
3534             \(
3535             my $val =
3536             $default_value
3537             )
3538             ) eq 'SCALAR';
3539 0 0 0     0 }
      0        
3540             }
3541             )
3542             && (
3543             do {
3544             local $_ = $default_value;
3545             /\%/;
3546             }
3547 0         0 )
3548 0         0 )
3549             );
3550 323 50   323 0 1647 }
3551             or do {
3552              
3553             ( defined($default_value)
3554             and !ref($default_value)
3555             and $default_value =~ m{\A(?:1)\z} );
3556             }
3557             or ( !defined($default_value) )
3558 9 50       18 );
3559             or croak(
3560             "Type check failed in default: %s should be %s",
3561             "predicate",
3562             "MethodNameTemplate|One|Undef"
3563             );
3564             $default_value;
3565             }
3566             )
3567             )
3568             }
3569             }
3570              
3571 9 50       41 # Accessors for reader
3572 9 50       90 # has declaration, file lib/Mite/Attribute.pm, line 71
3573             @_ > 1
3574             ? do {
3575             do {
3576              
3577             (
3578             do {
3579 9         40  
  9         141  
3580             (
3581             (
3582             (
3583             do {
3584              
3585             defined( $_[1] ) and do {
3586             ref( \$_[1] ) eq 'SCALAR'
3587 0 0       0 or ref( \( my $val = $_[1] ) ) eq
3588 0 0       0 'SCALAR';
3589             }
3590             }
3591             )
3592             && (
3593             do { local $_ = $_[1]; /\A[^\W0-9]\w*\z/ }
3594             )
3595 9 50 0     16 )
  0   33     0  
  0         0  
3596             or (
3597             (
3598             do {
3599              
3600 9 0 33     16 defined( $_[1] ) and do {
3601             ref( \$_[1] ) eq 'SCALAR'
3602             or ref( \( my $val = $_[1] ) ) eq
3603 0 0 0     0 'SCALAR';
3604             }
3605             }
3606             )
3607             && (
3608             do { local $_ = $_[1]; /\%/ }
3609             )
3610             )
3611             );
3612 9         25 }
3613 9         30 or do {
3614              
3615 474 100   474 0 1228 ( defined( $_[1] )
3616             and !ref( $_[1] )
3617             and $_[1] =~ m{\A(?:1)\z} );
3618 465 100       1943 }
3619 156         662 or ( !defined( $_[1] ) )
3620 156 50       389 );
3621             or croak( "Type check failed in %s: value should be %s",
3622             "accessor", "MethodNameTemplate|One|Undef" );
3623             $_[0]{"reader"} = $_[1];
3624             $_[0];
3625             }
3626             : do {
3627             (
3628             exists( $_[0]{"reader"} ) ? $_[0]{"reader"} : (
3629             $_[0]{"reader"} = do {
3630             my $default_value = $_[0]->_build_reader;
3631             do {
3632              
3633             (
3634 156 50       1255 do {
3635 0 0       0  
3636             (
3637             (
3638             (
3639             do {
3640              
3641             defined($default_value)
3642             and do {
3643             ref( \$default_value )
3644             eq 'SCALAR'
3645             or ref(
3646             \(
3647             my $val =
3648 0         0 $default_value
3649 0         0 )
3650             ) eq 'SCALAR';
3651             }
3652             }
3653             )
3654             && (
3655             do {
3656             local $_ = $default_value;
3657             /\A[^\W0-9]\w*\z/;
3658             }
3659 156 50       1238 )
3660 0 0       0 )
3661             or (
3662             (
3663             do {
3664              
3665             defined($default_value)
3666             and do {
3667             ref( \$default_value )
3668             eq 'SCALAR'
3669             or ref(
3670             \(
3671             my $val =
3672 156 50 33     284 $default_value
      33        
3673 0         0 )
3674 0         0 ) eq 'SCALAR';
3675             }
3676             }
3677             )
3678             && (
3679             do {
3680 156 50 33     313 local $_ = $default_value;
3681             /\%/;
3682             }
3683 156 50 33     1267 )
3684             )
3685             );
3686             }
3687             or do {
3688              
3689             ( defined($default_value)
3690             and !ref($default_value)
3691             and $default_value =~ m{\A(?:1)\z} );
3692             }
3693             or ( !defined($default_value) )
3694             );
3695 156         694 or croak(
3696             "Type check failed in default: %s should be %s",
3697             "reader",
3698             "MethodNameTemplate|One|Undef"
3699             );
3700             $default_value;
3701             }
3702             )
3703             )
3704             }
3705             }
3706              
3707             # Accessors for required
3708             # has declaration, file lib/Mite/Attribute.pm, line 54
3709 0 0 0     0 @_ > 1
3710             ? do {
3711             my $value = do {
3712 0 0       0 my $to_coerce = $_[1];
3713 0 0       0 (
3714             (
3715             !ref $to_coerce
3716             and (!defined $to_coerce
3717             or $to_coerce eq q()
3718             or $to_coerce eq '0'
3719             or $to_coerce eq '1' )
3720             )
3721             ) ? $to_coerce
3722             : ( ( !!1 ) ) ? scalar( do { local $_ = $to_coerce; !!$_ } )
3723             : $to_coerce;
3724             };
3725 0         0 (
3726 0         0 !ref $value
3727             and (!defined $value
3728 1611 50   1611 0 27686 or $value eq q()
3729             or $value eq '0'
3730             or $value eq '1' )
3731             )
3732             or croak( "Type check failed in %s: value should be %s",
3733             "accessor", "Bool" );
3734             $_[0]{"required"} = $value;
3735             $_[0];
3736 4 50       19 }
3737             : ( $_[0]{"required"} );
3738             }
3739              
3740             # Accessors for skip_argc_check
3741             # has declaration, file lib/Mite/Attribute.pm, line 113
3742             @_ > 1
3743             ? do {
3744             my $value = do {
3745             my $to_coerce = $_[1];
3746             (
3747             (
3748             !ref $to_coerce
3749 4 50       35 and (!defined $to_coerce
3750 4 50       63 or $to_coerce eq q()
3751             or $to_coerce eq '0'
3752             or $to_coerce eq '1' )
3753             )
3754             ) ? $to_coerce
3755             : ( ( !!1 ) ) ? scalar( do { local $_ = $to_coerce; !!$_ } )
3756             : $to_coerce;
3757 4         15 };
  4         73  
3758             (
3759             !ref $value
3760             and (!defined $value
3761             or $value eq q()
3762             or $value eq '0'
3763             or $value eq '1' )
3764             )
3765 0 0       0 or croak( "Type check failed in %s: value should be %s",
3766 0 0       0 "accessor", "Bool" );
3767             $_[0]{"skip_argc_check"} = $value;
3768             $_[0];
3769             }
3770             : ( $_[0]{"skip_argc_check"} );
3771             }
3772              
3773 4 50 0     16 # Accessors for trigger
  0   33     0  
  0         0  
3774             # has declaration, file lib/Mite/Attribute.pm, line 134
3775             if ($__XS) {
3776             Class::XSAccessor->import(
3777             chained => 1,
3778 4 0 33     8 "exists_predicates" => { "has_trigger" => "trigger" },
3779             );
3780             }
3781 0 0 0     0 else {
3782             *has_trigger = sub {
3783             @_ == 1
3784             or croak('Predicate "has_trigger" usage: $self->has_trigger()');
3785             exists $_[0]{"trigger"};
3786             };
3787             }
3788              
3789             @_ > 1
3790 4         16 ? do {
3791 4         15 do {
3792              
3793 299 100   299 0 1008 (
3794             do {
3795              
3796 295 100       906 (
3797 162         621 (
3798 162 50       390 (
3799             do {
3800              
3801             defined( $_[1] ) and do {
3802             ref( \$_[1] ) eq 'SCALAR'
3803             or ref( \( my $val = $_[1] ) ) eq
3804             'SCALAR';
3805             }
3806             }
3807             )
3808             && (
3809             do { local $_ = $_[1]; /\A[^\W0-9]\w*\z/ }
3810             )
3811             )
3812 162 50       1207 or (
3813 0 0       0 (
3814             do {
3815              
3816             defined( $_[1] ) and do {
3817             ref( \$_[1] ) eq 'SCALAR'
3818             or ref( \( my $val = $_[1] ) ) eq
3819             'SCALAR';
3820             }
3821             }
3822             )
3823             && (
3824             do { local $_ = $_[1]; /\%/ }
3825             )
3826 0         0 )
3827 0         0 );
3828             }
3829             or do {
3830              
3831             ( defined( $_[1] )
3832             and !ref( $_[1] )
3833             and $_[1] =~ m{\A(?:1)\z} );
3834             }
3835             or ( ref( $_[1] ) eq 'CODE' )
3836             );
3837 162 50       1231 or croak( "Type check failed in %s: value should be %s",
3838 0 0       0 "accessor", "MethodNameTemplate|One|CodeRef" );
3839             $_[0]{"trigger"} = $_[1];
3840             $_[0];
3841             }
3842             : ( $_[0]{"trigger"} );
3843             }
3844              
3845             # Accessors for type
3846             # has declaration, file lib/Mite/Attribute.pm, line 92
3847             @_ == 1 or croak('Reader "type" usage: $self->type()');
3848             (
3849             exists( $_[0]{"type"} ) ? $_[0]{"type"} : (
3850 162 50 33     296 $_[0]{"type"} = do {
      33        
3851 0         0 my $default_value = $_[0]->_build_type;
3852 0         0 do {
3853              
3854             (
3855             (
3856             do {
3857              
3858 162 50 33     308 use Scalar::Util ();
3859             Scalar::Util::blessed($default_value);
3860             }
3861 162 50 33     1356 )
3862             or ( !defined($default_value) )
3863             );
3864             or croak( "Type check failed in default: %s should be %s",
3865             "type", "Object|Undef" );
3866             $default_value;
3867             }
3868             )
3869             );
3870             }
3871              
3872             # Accessors for weak_ref
3873 162         680 # has declaration, file lib/Mite/Attribute.pm, line 61
3874             @_ > 1
3875             ? do {
3876             (
3877             !ref $_[1]
3878             and (!defined $_[1]
3879             or $_[1] eq q()
3880             or $_[1] eq '0'
3881             or $_[1] eq '1' )
3882             )
3883             or croak( "Type check failed in %s: value should be %s",
3884             "accessor", "Bool" );
3885 3 50       13 $_[0]{"weak_ref"} = $_[1];
3886             $_[0];
3887             }
3888             : ( $_[0]{"weak_ref"} );
3889             }
3890              
3891             # Accessors for writer
3892             # has declaration, file lib/Mite/Attribute.pm, line 71
3893             @_ > 1
3894             ? do {
3895             do {
3896              
3897             (
3898 3 50       36 do {
3899 3 50       52  
3900             (
3901             (
3902             (
3903             do {
3904              
3905             defined( $_[1] ) and do {
3906 3         11 ref( \$_[1] ) eq 'SCALAR'
  3         99  
3907             or ref( \( my $val = $_[1] ) ) eq
3908             'SCALAR';
3909             }
3910             }
3911             )
3912             && (
3913             do { local $_ = $_[1]; /\A[^\W0-9]\w*\z/ }
3914 0 0       0 )
3915 0 0       0 )
3916             or (
3917             (
3918             do {
3919              
3920             defined( $_[1] ) and do {
3921             ref( \$_[1] ) eq 'SCALAR'
3922 3 50 0     7 or ref( \( my $val = $_[1] ) ) eq
  0   33     0  
  0         0  
3923             'SCALAR';
3924             }
3925             }
3926             )
3927 3 0 33     10 && (
3928             do { local $_ = $_[1]; /\%/ }
3929             )
3930 0 0 0     0 )
3931             );
3932             }
3933             or do {
3934              
3935             ( defined( $_[1] )
3936             and !ref( $_[1] )
3937             and $_[1] =~ m{\A(?:1)\z} );
3938             }
3939 3         10 or ( !defined( $_[1] ) )
3940 3         14 );
3941             or croak( "Type check failed in %s: value should be %s",
3942 302 100   302 0 951 "accessor", "MethodNameTemplate|One|Undef" );
3943             $_[0]{"writer"} = $_[1];
3944             $_[0];
3945 299 100       989 }
3946 162         856 : do {
3947 162 50       347 (
3948             exists( $_[0]{"writer"} ) ? $_[0]{"writer"} : (
3949             $_[0]{"writer"} = do {
3950             my $default_value = $_[0]->_build_writer;
3951             do {
3952              
3953             (
3954             do {
3955              
3956             (
3957             (
3958             (
3959             do {
3960              
3961 162 100       1205 defined($default_value)
3962 54 50       529 and do {
3963             ref( \$default_value )
3964             eq 'SCALAR'
3965             or ref(
3966             \(
3967             my $val =
3968             $default_value
3969             )
3970             ) eq 'SCALAR';
3971             }
3972             }
3973             )
3974             && (
3975 54         155 do {
3976 54         531 local $_ = $default_value;
3977             /\A[^\W0-9]\w*\z/;
3978             }
3979             )
3980             )
3981             or (
3982             (
3983             do {
3984              
3985             defined($default_value)
3986 162 100       1283 and do {
3987 54 50       425 ref( \$default_value )
3988             eq 'SCALAR'
3989             or ref(
3990             \(
3991             my $val =
3992             $default_value
3993             )
3994             ) eq 'SCALAR';
3995             }
3996             }
3997             )
3998             && (
3999 162 50 66     292 do {
      66        
4000 54         153 local $_ = $default_value;
4001 54         530 /\%/;
4002             }
4003             )
4004             )
4005             );
4006             }
4007 162 50 66     309 or do {
4008              
4009             ( defined($default_value)
4010 108 50 33     994 and !ref($default_value)
4011             and $default_value =~ m{\A(?:1)\z} );
4012             }
4013             or ( !defined($default_value) )
4014             );
4015             or croak(
4016             "Type check failed in default: %s should be %s",
4017             "writer",
4018             "MethodNameTemplate|One|Undef"
4019             );
4020             $default_value;
4021             }
4022 162         1038 )
4023             )
4024             }
4025             }
4026              
4027             # See UNIVERSAL
4028             my ( $self, $role ) = @_;
4029             our %DOES;
4030             return $DOES{$role} if exists $DOES{$role};
4031             return 1 if $role eq __PACKAGE__;
4032             if ( $INC{'Moose/Util.pm'}
4033             and my $meta = Moose::Util::find_meta( ref $self or $self ) )
4034 0         0 {
4035 0         0 $meta->can('does_role') and $meta->does_role($role) and return 1;
4036             }
4037             return $self->SUPER::DOES($role);
4038             }
4039              
4040             # Alias for Moose/Moo-compatibility
4041             shift->DOES(@_);
4042             }
4043              
4044             1;