Profile of /usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types/Base.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For 05.Domain_and_Item.t
Run on Tue May 4 17:21:41 2010
Reported on Tue May 4 17:22:21 2010

File | /usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types/Base.pm
Statements Executed | 1126
Statement Execution Time | 3.01ms

Subroutines — ordered by exclusive time
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
4 | 4 | 4 | 1.10ms | 12.8ms | MooseX::Types::Base::::importMooseX::Types::Base::import
1 | 1 | 1 | 1.02ms | 4.79ms | MooseX::Types::Base::::BEGIN@15MooseX::Types::Base::BEGIN@15
1 | 1 | 1 | 315µs | 496µs | MooseX::Types::Base::::BEGIN@11MooseX::Types::Base::BEGIN@11
52 | 1 | 1 | 275µs | 589µs | MooseX::Types::Base::::get_typeMooseX::Types::Base::get_type
52 | 1 | 1 | 170µs | 245µs | MooseX::Types::Base::::has_typeMooseX::Types::Base::has_type
73 | 4 | 1 | 148µs | 148µs | MooseX::Types::Base::::type_storageMooseX::Types::Base::type_storage
35 | 1 | 1 | 132µs | 435µs | MooseX::Types::Base::::__ANON__[:72]MooseX::Types::Base::__ANON__[:72]
35 | 1 | 1 | 111µs | 266µs | MooseX::Types::Base::::__ANON__[:77]MooseX::Types::Base::__ANON__[:77]
30 | 1 | 1 | 90µs | 199µs | MooseX::Types::Base::::__ANON__[:85]MooseX::Types::Base::__ANON__[:85]
10 | 1 | 1 | 43µs | 64µs | MooseX::Types::Base::::add_typeMooseX::Types::Base::add_type
4 | 1 | 1 | 35µs | 48µs | MooseX::Types::Base::::type_namesMooseX::Types::Base::type_names
1 | 1 | 1 | 18µs | 29µs | MooseX::Types::Base::::BEGIN@243MooseX::Types::Base::BEGIN@243
1 | 1 | 1 | 17µs | 2.37ms | MooseX::Types::Base::::BEGIN@2MooseX::Types::Base::BEGIN@2
1 | 1 | 1 | 15µs | 24µs | MooseX::Types::Base::::register_class_typeMooseX::Types::Base::register_class_type
1 | 1 | 1 | 10µs | 145µs | MooseX::Types::Base::::BEGIN@12MooseX::Types::Base::BEGIN@12
2 | 2 | 1 | 10µs | 10µs | MooseX::Types::Base::::registered_class_typesMooseX::Types::Base::registered_class_types
1 | 1 | 1 | 9µs | 1.21ms | MooseX::Types::Base::::BEGIN@13MooseX::Types::Base::BEGIN@13
1 | 1 | 1 | 9µs | 100µs | MooseX::Types::Base::::BEGIN@10MooseX::Types::Base::BEGIN@10
1 | 1 | 1 | 7µs | 19µs | MooseX::Types::Base::::BEGIN@186MooseX::Types::Base::BEGIN@186
1 | 1 | 1 | 7µs | 10µs | MooseX::Types::Base::::get_registered_class_typeMooseX::Types::Base::get_registered_class_type
1 | 1 | 1 | 7µs | 16µs | MooseX::Types::Base::::BEGIN@201MooseX::Types::Base::BEGIN@201
0 | 0 | 0 | 0s | 0s | MooseX::Types::Base::::get_registered_role_typeMooseX::Types::Base::get_registered_role_type
0 | 0 | 0 | 0s | 0s | MooseX::Types::Base::::register_role_typeMooseX::Types::Base::register_role_type
0 | 0 | 0 | 0s | 0s | MooseX::Types::Base::::registered_role_typesMooseX::Types::Base::registered_role_types

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package MooseX::Types::Base;
2 | 3 | 35µs | 2 | 4.73ms | # spent 2.37ms (17µs+2.36) within MooseX::Types::Base::BEGIN@2 which was called # once (17µs+2.36ms) by MooseX::Types::BEGIN@12 at line 2 use Moose; # spent 2.37ms making 1 call to MooseX::Types::Base::BEGIN@2 # spent 2.36ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:389]
3 |  |  |  |  |
4 |  |  |  |  | =head1 NAME
5 |  |  |  |  |
6 |  |  |  |  | MooseX::Types::Base - Type library base class
7 |  |  |  |  |
8 |  |  |  |  | =cut
9 |  |  |  |  |
10 | 3 | 29µs | 2 | 192µs | # spent 100µs (9+92) within MooseX::Types::Base::BEGIN@10 which was called # once (9µs+92µs) by MooseX::Types::BEGIN@12 at line 10 use Carp::Clan qw( ^MooseX::Types ); # spent 100µs making 1 call to MooseX::Types::Base::BEGIN@10 # spent 92µs making 1 call to Carp::Clan::import
11 | 3 | 120µs | 2 | 534µs | # spent 496µs (315+181) within MooseX::Types::Base::BEGIN@11 which was called # once (315µs+181µs) by MooseX::Types::BEGIN@12 at line 11 use MooseX::Types::Util qw( filter_tags ); # spent 496µs making 1 call to MooseX::Types::Base::BEGIN@11 # spent 38µs making 1 call to Exporter::import
12 | 3 | 30µs | 2 | 280µs | # spent 145µs (10+135) within MooseX::Types::Base::BEGIN@12 which was called # once (10µs+135µs) by MooseX::Types::BEGIN@12 at line 12 use Sub::Exporter qw( build_exporter ); # spent 145µs making 1 call to MooseX::Types::Base::BEGIN@12 # spent 135µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
13 | 3 | 31µs | 2 | 2.41ms | # spent 1.21ms (9µs+1.20) within MooseX::Types::Base::BEGIN@13 which was called # once (9µs+1.20ms) by MooseX::Types::BEGIN@12 at line 13 use Moose::Util::TypeConstraints; # spent 1.21ms making 1 call to MooseX::Types::Base::BEGIN@13 # spent 1.20ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:389]
14 |  |  |  |  |
15 | 3 | 603µs | 2 | 5.50ms | # spent 4.79ms (1.02+3.77) within MooseX::Types::Base::BEGIN@15 which was called # once (1.02ms+3.77ms) by MooseX::Types::BEGIN@12 at line 15 use namespace::clean -except => [qw( meta )]; # spent 4.79ms making 1 call to MooseX::Types::Base::BEGIN@15 # spent 707µs making 1 call to namespace::clean::import
16 |  |  |  |  |
17 |  |  |  |  | =head1 DESCRIPTION
18 |  |  |  |  |
19 |  |  |  |  | You normally won't need to interact with this class by yourself. It is
20 |  |  |  |  | merely a collection of functionality that type libraries need to
21 |  |  |  |  | interact with moose and the rest of the L<MooseX::Types> module.
22 |  |  |  |  |
23 |  |  |  |  | =cut
24 |  |  |  |  |
25 | 1 | 500ns |  |  | my $UndefMsg = q{Unable to find type '%s' in library '%s'};
26 |  |  |  |  |
27 |  |  |  |  | =head1 METHODS
28 |  |  |  |  |
29 |  |  |  |  | =cut
30 |  |  |  |  |
31 |  |  |  |  | =head2 import
32 |  |  |  |  |
33 |  |  |  |  | Provides the import mechanism for your library. See
34 |  |  |  |  | L<MooseX::Types/"LIBRARY USAGE"> for syntax details on this.
35 |  |  |  |  |
36 |  |  |  |  | =cut
37 |  |  |  |  |
38 |  |  |  |  | # spent 12.8ms (1.10+11.7) within MooseX::Types::Base::import which was called 4 times, avg 3.19ms/call: # once (257µs+3.32ms) by SimpleDB::Class::Item::BEGIN@19 at line 19 of ../lib/SimpleDB/Class/Item.pm # once (245µs+3.15ms) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 4 of ../lib/SimpleDB/Class/Role/Itemized.pm # once (223µs+2.88ms) by MooseX::Types::import at line 358 of MooseX/Types.pm # once (379µs+2.32ms) by SimpleDB::Class::Types::BEGIN@83 at line 83 of ../lib/SimpleDB/Class/Types.pm sub import {
39 | 478 | 844µs |  |  | my ($class, @args) = @_;
40 |  |  |  |  |
41 |  |  |  |  | # filter or create options hash for S:E
42 |  |  |  |  | my $options = (@args and (ref($args[0]) eq 'HASH')) ? $args[0] : undef;
43 |  |  |  |  | unless ($options) {
44 |  |  |  |  | $options = {foo => 23};
45 |  |  |  |  | unshift @args, $options;
46 |  |  |  |  | }
47 |  |  |  |  |
48 |  |  |  |  | # all types known to us
49 |  |  |  |  | my @types = $class->type_names; # spent 48µs making 4 calls to MooseX::Types::Base::type_names, avg 12µs/call
50 |  |  |  |  |
51 |  |  |  |  | # determine the wrapper, -into is supported for compatibility reasons
52 |  |  |  |  | my $wrapper = $options->{ -wrapper } || 'MooseX::Types';
53 |  |  |  |  | $args[0]->{into} = $options->{ -into }
54 |  |  |  |  | if exists $options->{ -into };
55 |  |  |  |  |
56 |  |  |  |  | my (%ex_spec, %ex_util);
57 |  |  |  |  | TYPE:
58 |  |  |  |  | for my $type_short (@types) {
59 |  |  |  |  |
60 |  |  |  |  | # find type name and object, create undefined message
61 |  |  |  |  | my $type_full = $class->get_type($type_short) # spent 589µs making 52 calls to MooseX::Types::Base::get_type, avg 11µs/call
62 |  |  |  |  | or croak "No fully qualified type name stored for '$type_short'";
63 |  |  |  |  | my $type_cons = find_type_constraint($type_full); # spent 821µs making 52 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 16µs/call
64 |  |  |  |  | my $undef_msg = sprintf($UndefMsg, $type_short, $class);
65 |  |  |  |  |
66 |  |  |  |  | # the type itself
67 |  |  |  |  | push @{ $ex_spec{exports} },
68 |  |  |  |  | $type_short,
69 |  |  |  |  | # spent 435µs (132+303) within MooseX::Types::Base::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types/Base.pm:72] which was called 35 times, avg 12µs/call: # 35 times (132µs+303µs) by Sub::Exporter::default_generator at line 856 of Sub/Exporter.pm, avg 12µs/call sub {
70 | 35 | 122µs | 35 | 303µs | bless $wrapper->type_export_generator($type_short, $type_full), # spent 303µs making 35 calls to MooseX::Types::type_export_generator, avg 9µs/call
71 |  |  |  |  | 'MooseX::Types::EXPORTED_TYPE_CONSTRAINT';
72 |  |  |  |  | };
73 |  |  |  |  |
74 |  |  |  |  | # the check helper
75 |  |  |  |  | push @{ $ex_spec{exports} },
76 |  |  |  |  | "is_${type_short}",
77 | 35 | 87µs | 35 | 155µs | # spent 266µs (111+155) within MooseX::Types::Base::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types/Base.pm:77] which was called 35 times, avg 8µs/call: # 35 times (111µs+155µs) by Sub::Exporter::default_generator at line 856 of Sub/Exporter.pm, avg 8µs/call sub { $wrapper->check_export_generator($type_short, $type_full, $undef_msg) }; # spent 155µs making 35 calls to MooseX::Types::check_export_generator, avg 4µs/call
78 |  |  |  |  |
79 |  |  |  |  | # only export coercion helper if full (for libraries) or coercion is defined
80 |  |  |  |  | next TYPE
81 |  |  |  |  | unless $options->{ -full }
82 | 1 | 44µs | 84 | 289µs | or ($type_cons and $type_cons->has_coercion); # spent 235µs making 42 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:8], avg 6µs/call # spent 54µs making 42 calls to Moose::Meta::TypeConstraint::has_coercion, avg 1µs/call
83 |  |  |  |  | push @{ $ex_spec{exports} },
84 |  |  |  |  | "to_${type_short}",
85 | 30 | 71µs | 30 | 109µs | # spent 199µs (90+109) within MooseX::Types::Base::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types/Base.pm:85] which was called 30 times, avg 7µs/call: # 30 times (90µs+109µs) by Sub::Exporter::default_generator at line 856 of Sub/Exporter.pm, avg 7µs/call sub { $wrapper->coercion_export_generator($type_short, $type_full, $undef_msg) }; # spent 109µs making 30 calls to MooseX::Types::coercion_export_generator, avg 4µs/call
86 |  |  |  |  | $ex_util{ $type_short }{to}++; # shortcut to remember this exists
87 |  |  |  |  | }
88 |  |  |  |  |
89 |  |  |  |  | # create S:E exporter and increase export level unless specified explicitly
90 |  |  |  |  | my $exporter = build_exporter \%ex_spec; # spent 2.74ms making 4 calls to Sub::Exporter::build_exporter, avg 684µs/call
91 |  |  |  |  | $options->{into_level}++
92 |  |  |  |  | unless $options->{into};
93 |  |  |  |  |
94 |  |  |  |  | # remember requested symbols to determine what helpers to auto-export
95 |  |  |  |  | my %was_requested =
96 |  |  |  |  | map { ($_ => 1) }
97 |  |  |  |  | grep { not ref }
98 |  |  |  |  | @args;
99 |  |  |  |  |
100 |  |  |  |  | # determine which additional symbols (helpers) to export along
101 |  |  |  |  | my %add;
102 |  |  |  |  | EXPORT:
103 |  |  |  |  | for my $type (grep { exists $was_requested{ $_ } } @types) {
104 |  |  |  |  | $add{ "is_$type" }++
105 |  |  |  |  | unless $was_requested{ "is_$type" };
106 |  |  |  |  | next EXPORT
107 |  |  |  |  | unless exists $ex_util{ $type }{to};
108 |  |  |  |  | $add{ "to_$type" }++
109 |  |  |  |  | unless $was_requested{ "to_$type" };
110 |  |  |  |  | }
111 |  |  |  |  |
112 |  |  |  |  | # and on to the real exporter
113 |  |  |  |  | my @new_args = (@args, keys %add);
114 |  |  |  |  | return $class->$exporter(@new_args); # spent 7.18ms making 4 calls to Sub::Exporter::__ANON__[Sub/Exporter.pm:756], avg 1.80ms/call
115 |  |  |  |  | }
116 |  |  |  |  |
117 |  |  |  |  | =head2 get_type
118 |  |  |  |  |
119 |  |  |  |  | This returns a type from the library's store by its name.
120 |  |  |  |  |
121 |  |  |  |  | =cut
122 |  |  |  |  |
123 |  |  |  |  | # spent 589µs (275+313) within MooseX::Types::Base::get_type which was called 52 times, avg 11µs/call: # 52 times (275µs+313µs) by MooseX::Types::Base::import at line 61, avg 11µs/call sub get_type {
124 | 156 | 204µs |  |  | my ($class, $type) = @_;
125 |  |  |  |  |
126 |  |  |  |  | # useful message if the type couldn't be found
127 |  |  |  |  | croak "Unknown type '$type' in library '$class'" # spent 245µs making 52 calls to MooseX::Types::Base::has_type, avg 5µs/call
128 |  |  |  |  | unless $class->has_type($type);
129 |  |  |  |  |
130 |  |  |  |  | # return real name of the type
131 |  |  |  |  | return $class->type_storage->{ $type }; # spent 55µs making 30 calls to MooseX::Types::Base::type_storage, avg 2µs/call # spent 13µs making 22 calls to MooseX::Types::Moose::type_storage, avg 605ns/call
132 |  |  |  |  | }
133 |  |  |  |  |
134 |  |  |  |  | =head2 type_names
135 |  |  |  |  |
136 |  |  |  |  | Returns a list of all known types by their name.
137 |  |  |  |  |
138 |  |  |  |  | =cut
139 |  |  |  |  |
140 |  |  |  |  | # spent 48µs (35+13) within MooseX::Types::Base::type_names which was called 4 times, avg 12µs/call: # 4 times (35µs+13µs) by MooseX::Types::Base::import at line 49, avg 12µs/call sub type_names {
141 | 8 | 27µs |  |  | my ($class) = @_;
142 |  |  |  |  |
143 |  |  |  |  | # return short names of all stored types
144 |  |  |  |  | return keys %{ $class->type_storage }; # spent 13µs making 3 calls to MooseX::Types::Base::type_storage, avg 4µs/call # spent 800ns making 1 call to MooseX::Types::Moose::type_storage
145 |  |  |  |  | }
146 |  |  |  |  |
147 |  |  |  |  | =head2 add_type
148 |  |  |  |  |
149 |  |  |  |  | Adds a new type to the library.
150 |  |  |  |  |
151 |  |  |  |  | =cut
152 |  |  |  |  |
153 |  |  |  |  | # spent 64µs (43+20) within MooseX::Types::Base::add_type which was called 10 times, avg 6µs/call: # 10 times (43µs+20µs) by MooseX::Types::import at line 354 of MooseX/Types.pm, avg 6µs/call sub add_type {
154 | 20 | 38µs |  |  | my ($class, $type) = @_;
155 |  |  |  |  |
156 |  |  |  |  | # store type with library prefix as real name
157 |  |  |  |  | $class->type_storage->{ $type } = "${class}::${type}"; # spent 20µs making 10 calls to MooseX::Types::Base::type_storage, avg 2µs/call
158 |  |  |  |  | }
159 |  |  |  |  |
160 |  |  |  |  | =head2 has_type
161 |  |  |  |  |
162 |  |  |  |  | Returns true or false depending on if this library knows a type by that
163 |  |  |  |  | name.
164 |  |  |  |  |
165 |  |  |  |  | =cut
166 |  |  |  |  |
167 |  |  |  |  | # spent 245µs (170+75) within MooseX::Types::Base::has_type which was called 52 times, avg 5µs/call: # 52 times (170µs+75µs) by MooseX::Types::Base::get_type at line 127, avg 5µs/call sub has_type {
168 | 104 | 139µs |  |  | my ($class, $type) = @_;
169 |  |  |  |  |
170 |  |  |  |  | # check if we stored a type under that name
171 |  |  |  |  | return ! ! $class->type_storage->{ $type }; # spent 60µs making 30 calls to MooseX::Types::Base::type_storage, avg 2µs/call # spent 15µs making 22 calls to MooseX::Types::Moose::type_storage, avg 682ns/call
172 |  |  |  |  | }
173 |  |  |  |  |
174 |  |  |  |  | =head2 type_storage
175 |  |  |  |  |
176 |  |  |  |  | Returns the library's type storage hash reference. You shouldn't use this
177 |  |  |  |  | method directly unless you know what you are doing. It is not an internal
178 |  |  |  |  | method because overriding it makes virtual libraries very easy.
179 |  |  |  |  |
180 |  |  |  |  | =cut
181 |  |  |  |  |
182 |  |  |  |  | # spent 148µs within MooseX::Types::Base::type_storage which was called 73 times, avg 2µs/call: # 30 times (60µs+0s) by MooseX::Types::Base::has_type at line 171, avg 2µs/call # 30 times (55µs+0s) by MooseX::Types::Base::get_type at line 131, avg 2µs/call # 10 times (20µs+0s) by MooseX::Types::Base::add_type at line 157, avg 2µs/call # 3 times (13µs+0s) by MooseX::Types::Base::type_names at line 144, avg 4µs/call sub type_storage {
183 | 219 | 205µs |  |  | my ($class) = @_;
184 |  |  |  |  |
185 |  |  |  |  | # return a reference to the storage in ourself
186 | 3 | 55µs | 2 | 30µs | # spent 19µs (7+11) within MooseX::Types::Base::BEGIN@186 which was called # once (7µs+11µs) by MooseX::Types::BEGIN@12 at line 186 { no strict 'refs'; # spent 19µs making 1 call to MooseX::Types::Base::BEGIN@186 # spent 11µs making 1 call to strict::unimport
187 |  |  |  |  | return \%{ $class . '::__MOOSEX_TYPELIBRARY_STORAGE' };
188 |  |  |  |  | }
189 |  |  |  |  | }
190 |  |  |  |  |
191 |  |  |  |  | =head2 registered_class_types
192 |  |  |  |  |
193 |  |  |  |  | Returns the class types registered within this library. Don't use directly.
194 |  |  |  |  |
195 |  |  |  |  | =cut
196 |  |  |  |  |
197 |  |  |  |  | # spent 10µs within MooseX::Types::Base::registered_class_types which was called 2 times, avg 5µs/call: # once (7µs+0s) by MooseX::Types::Base::register_class_type at line 218 # once (3µs+0s) by MooseX::Types::Base::get_registered_class_type at line 230 sub registered_class_types {
198 | 6 | 14µs |  |  | my ($class) = @_;
199 |  |  |  |  |
200 |  |  |  |  | {
201 | 3 | 143µs | 2 | 26µs | # spent 16µs (7+9) within MooseX::Types::Base::BEGIN@201 which was called # once (7µs+9µs) by MooseX::Types::BEGIN@12 at line 201 no strict 'refs'; # spent 16µs making 1 call to MooseX::Types::Base::BEGIN@201 # spent 9µs making 1 call to strict::unimport
202 |  |  |  |  | return \%{ $class . '::__MOOSEX_TYPELIBRARY_CLASS_TYPES' };
203 |  |  |  |  | }
204 |  |  |  |  | }
205 |  |  |  |  |
206 |  |  |  |  | =head2 register_class_type
207 |  |  |  |  |
208 |  |  |  |  | Register a C<class_type> for use in this library by class name.
209 |  |  |  |  |
210 |  |  |  |  | =cut
211 |  |  |  |  |
212 |  |  |  |  | # spent 24µs (15+9) within MooseX::Types::Base::register_class_type which was called # once (15µs+9µs) by MooseX::Types::CheckedUtilExports::class_type at line 73 of MooseX/Types/CheckedUtilExports.pm sub register_class_type {
213 | 3 | 13µs |  |  | my ($class, $type) = @_;
214 |  |  |  |  |
215 |  |  |  |  | croak "Not a class_type" # spent 600ns making 1 call to UNIVERSAL::isa
216 |  |  |  |  | unless $type->isa('Moose::Meta::TypeConstraint::Class');
217 |  |  |  |  |
218 |  |  |  |  | $class->registered_class_types->{$type->class} = $type; # spent 7µs making 1 call to MooseX::Types::Base::registered_class_types # spent 2µs making 1 call to Moose::Meta::TypeConstraint::Class::class
219 |  |  |  |  | }
220 |  |  |  |  |
221 |  |  |  |  | =head2 get_registered_class_type
222 |  |  |  |  |
223 |  |  |  |  | Get a C<class_type> registered in this library by name.
224 |  |  |  |  |
225 |  |  |  |  | =cut
226 |  |  |  |  |
227 |  |  |  |  | # spent 10µs (7+3) within MooseX::Types::Base::get_registered_class_type which was called # once (7µs+3µs) by MooseX::Types::CheckedUtilExports::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types/CheckedUtilExports.pm:63] at line 56 of MooseX/Types/CheckedUtilExports.pm sub get_registered_class_type {
228 | 2 | 6µs |  |  | my ($class, $name) = @_;
229 |  |  |  |  |
230 |  |  |  |  | $class->registered_class_types->{$name}; # spent 3µs making 1 call to MooseX::Types::Base::registered_class_types
231 |  |  |  |  | }
232 |  |  |  |  |
233 |  |  |  |  | =head2 registered_role_types
234 |  |  |  |  |
235 |  |  |  |  | Returns the role types registered within this library. Don't use directly.
236 |  |  |  |  |
237 |  |  |  |  | =cut
238 |  |  |  |  |
239 |  |  |  |  | sub registered_role_types {
240 |  |  |  |  | my ($class) = @_;
241 |  |  |  |  |
242 |  |  |  |  | {
243 | 3 | 123µs | 2 | 39µs | # spent 29µs (18+10) within MooseX::Types::Base::BEGIN@243 which was called # once (18µs+10µs) by MooseX::Types::BEGIN@12 at line 243 no strict 'refs'; # spent 29µs making 1 call to MooseX::Types::Base::BEGIN@243 # spent 10µs making 1 call to strict::unimport
244 |  |  |  |  | return \%{ $class . '::__MOOSEX_TYPELIBRARY_ROLE_TYPES' };
245 |  |  |  |  | }
246 |  |  |  |  | }
247 |  |  |  |  |
248 |  |  |  |  | =head2 register_role_type
249 |  |  |  |  |
250 |  |  |  |  | Register a C<role_type> for use in this library by role name.
251 |  |  |  |  |
252 |  |  |  |  | =cut
253 |  |  |  |  |
254 |  |  |  |  | sub register_role_type {
255 |  |  |  |  | my ($class, $type) = @_;
256 |  |  |  |  |
257 |  |  |  |  | croak "Not a role_type"
258 |  |  |  |  | unless $type->isa('Moose::Meta::TypeConstraint::Role');
259 |  |  |  |  |
260 |  |  |  |  | $class->registered_role_types->{$type->role} = $type;
261 |  |  |  |  | }
262 |  |  |  |  |
263 |  |  |  |  | =head2 get_registered_role_type
264 |  |  |  |  |
265 |  |  |  |  | Get a C<role_type> registered in this library by role name.
266 |  |  |  |  |
267 |  |  |  |  | =cut
268 |  |  |  |  |
269 |  |  |  |  | sub get_registered_role_type {
270 |  |  |  |  | my ($class, $name) = @_;
271 |  |  |  |  |
272 |  |  |  |  | $class->registered_role_types->{$name};
273 |  |  |  |  | }
274 |  |  |  |  |
275 |  |  |  |  | =head1 SEE ALSO
276 |  |  |  |  |
277 |  |  |  |  | L<MooseX::Types::Moose>
278 |  |  |  |  |
279 |  |  |  |  | =head1 AUTHOR
280 |  |  |  |  |
281 |  |  |  |  | See L<MooseX::Types/AUTHOR>.
282 |  |  |  |  |
283 |  |  |  |  | =head1 LICENSE
284 |  |  |  |  |
285 |  |  |  |  | This program is free software; you can redistribute it and/or modify
286 |  |  |  |  | it under the same terms as perl itself.
287 |  |  |  |  |
288 |  |  |  |  | =cut
289 |  |  |  |  |
290 | 1 | 22µs | 1 | 1.96ms | 1; # spent 1.96ms making 1 call to B::Hooks::EndOfScope::__ANON__[B/Hooks/EndOfScope.pm:47]