7 use warnings FATAL => 'redefine'; # to avoid to load Mouse::PurePerl
14 return 0 if ref($class) || !defined($class) || !length($class);
16 # walk the symbol table tree to avoid autovififying
17 # \*{${main::}{"Foo::"}} == \*main::Foo::
20 foreach my $part (split('::', $class)) {
21 my $entry = \$pack->{$part . '::'};
22 return 0 if ref($entry) ne 'GLOB';
23 $pack = *{$entry}{HASH} or return 0;
26 # check for $VERSION or @ISA
27 return 1 if exists $pack->{VERSION}
28 && defined *{$pack->{VERSION}}{SCALAR} && defined ${ $pack->{VERSION} };
29 return 1 if exists $pack->{ISA}
30 && defined *{$pack->{ISA}}{ARRAY} && @{ $pack->{ISA} } != 0;
32 # check for any method
33 foreach my $name( keys %{$pack} ) {
34 my $entry = \$pack->{$name};
35 return 1 if ref($entry) ne 'GLOB' || defined *{$entry}{CODE};
43 # taken from Sub::Identify
46 ref($coderef) or return;
48 my $cv = B::svref_2object($coderef);
49 $cv->isa('B::CV') or return;
52 $gv->isa('B::GV') or return;
54 return ($gv->STASH->NAME, $gv->NAME);
60 my $cv = B::svref_2object($coderef);
61 $cv->isa('B::CV') or return '';
64 $gv->isa('B::GV') or return '';
66 return $gv->STASH->NAME;
72 sub name { $_[0]->{package} }
75 my $name = $_[0]->{package};
77 return \%{ $name . '::' };
84 return exists $_[0]->{anon_serial_id};
87 sub roles { $_[0]->{roles} }
89 sub linearized_isa { @{ get_linear_isa($_[0]->{package}) } }
95 return exists $_[0]->{anon_serial_id};
98 sub get_roles { $_[0]->{roles} }
101 Mouse::Meta::Attribute;
106 sub name { $_[0]->{name} }
107 sub associated_class { $_[0]->{associated_class} }
109 sub accessor { $_[0]->{accessor} }
110 sub reader { $_[0]->{reader} }
111 sub writer { $_[0]->{writer} }
112 sub predicate { $_[0]->{predicate} }
113 sub clearer { $_[0]->{clearer} }
114 sub handles { $_[0]->{handles} }
116 sub _is_metadata { $_[0]->{is} }
117 sub is_required { $_[0]->{required} }
118 sub default { $_[0]->{default} }
119 sub is_lazy { $_[0]->{lazy} }
120 sub is_lazy_build { $_[0]->{lazy_build} }
121 sub is_weak_ref { $_[0]->{weak_ref} }
122 sub init_arg { $_[0]->{init_arg} }
123 sub type_constraint { $_[0]->{type_constraint} }
125 sub trigger { $_[0]->{trigger} }
126 sub builder { $_[0]->{builder} }
127 sub should_auto_deref { $_[0]->{auto_deref} }
128 sub should_coerce { $_[0]->{coerce} }
132 sub has_accessor { exists $_[0]->{accessor} }
133 sub has_reader { exists $_[0]->{reader} }
134 sub has_writer { exists $_[0]->{writer} }
135 sub has_predicate { exists $_[0]->{predicate} }
136 sub has_clearer { exists $_[0]->{clearer} }
137 sub has_handles { exists $_[0]->{handles} }
139 sub has_default { exists $_[0]->{default} }
140 sub has_type_constraint { exists $_[0]->{type_constraint} }
141 sub has_trigger { exists $_[0]->{trigger} }
142 sub has_builder { exists $_[0]->{builder} }
145 Mouse::Meta::TypeConstraint;
147 sub name { $_[0]->{name} }
148 sub parent { $_[0]->{parent} }
149 sub message { $_[0]->{message} }
151 sub _compiled_type_constraint{ $_[0]->{compiled_type_constraint} }
153 sub has_coercion{ exists $_[0]->{_compiled_type_coercion} }
156 Mouse::Meta::Method::Accessor;