Profile of /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Meta/TypeConstraint.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:54 2010

File | /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Meta/TypeConstraint.pm
Statements Executed | 11643
Statement Execution Time | 20.5ms

Subroutines — ordered by exclusive time
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
831 | 6 | 6 | 5.56ms | 20.4ms | Moose::Meta::TypeConstraint::::checkMoose::Meta::TypeConstraint::check
933 | 19 | 11 | 3.16ms | 4.65ms | Moose::Meta::TypeConstraint::::__ANON__[:8]Moose::Meta::TypeConstraint::__ANON__[:8]
431 | 5 | 4 | 3.10ms | 60.2ms | Moose::Meta::TypeConstraint::::coerceMoose::Meta::TypeConstraint::coerce
54 | 2 | 1 | 782µs | 1.54ms | Moose::Meta::TypeConstraint::::equalsMoose::Meta::TypeConstraint::equals
41 | 10 | 6 | 728µs | 7.78ms | Moose::Meta::TypeConstraint::::newMoose::Meta::TypeConstraint::new
90 | 1 | 1 | 681µs | 2.61ms | Moose::Meta::TypeConstraint::::_actually_compile_type_constraintMoose::Meta::TypeConstraint::_actually_compile_type_constraint
91 | 4 | 4 | 570µs | 3.40ms | Moose::Meta::TypeConstraint::::compile_type_constraintMoose::Meta::TypeConstraint::compile_type_constraint
23 | 1 | 1 | 555µs | 1.27ms | Moose::Meta::TypeConstraint::::_compile_subtypeMoose::Meta::TypeConstraint::_compile_subtype
17 | 2 | 2 | 469µs | 2.60ms | Moose::Meta::TypeConstraint::::is_subtype_ofMoose::Meta::TypeConstraint::is_subtype_of
23 | 1 | 1 | 386µs | 530µs | Moose::Meta::TypeConstraint::::_collect_all_parentsMoose::Meta::TypeConstraint::_collect_all_parents
1 | 1 | 1 | 377µs | 587µs | Moose::Meta::TypeConstraint::::BEGIN@6Moose::Meta::TypeConstraint::BEGIN@6
66 | 1 | 1 | 311µs | 389µs | Moose::Meta::TypeConstraint::::_compile_hand_optimized_type_constraintMoose::Meta::TypeConstraint::_compile_hand_optimized_type_constraint
22 | 2 | 2 | 130µs | 1.78ms | Moose::Meta::TypeConstraint::::create_child_typeMoose::Meta::TypeConstraint::create_child_type
66 | 6 | 6 | 125µs | 125µs | Moose::Meta::TypeConstraint::::__ANON__[:30]Moose::Meta::TypeConstraint::__ANON__[:30]
2 | 1 | 1 | 34µs | 164µs | Moose::Meta::TypeConstraint::::is_a_type_ofMoose::Meta::TypeConstraint::is_a_type_of
1 | 1 | 1 | 14µs | 17µs | Moose::Meta::TypeConstraint::::BEGIN@4Moose::Meta::TypeConstraint::BEGIN@4
1 | 1 | 1 | 14µs | 28µs | Moose::Meta::TypeConstraint::::_compile_typeMoose::Meta::TypeConstraint::_compile_type
1 | 1 | 1 | 9µs | 56µs | Moose::Meta::TypeConstraint::::BEGIN@8Moose::Meta::TypeConstraint::BEGIN@8
1 | 1 | 1 | 7µs | 35µs | Moose::Meta::TypeConstraint::::BEGIN@11Moose::Meta::TypeConstraint::BEGIN@11
1 | 1 | 1 | 7µs | 16µs | Moose::Meta::TypeConstraint::::BEGIN@5Moose::Meta::TypeConstraint::BEGIN@5
1 | 1 | 1 | 7µs | 29µs | Moose::Meta::TypeConstraint::::BEGIN@12Moose::Meta::TypeConstraint::BEGIN@12
1 | 1 | 1 | 6µs | 45µs | Moose::Meta::TypeConstraint::::BEGIN@14Moose::Meta::TypeConstraint::BEGIN@14
0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeConstraint::::__ANON__[:253]Moose::Meta::TypeConstraint::__ANON__[:253]
0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeConstraint::::__ANON__[:266]Moose::Meta::TypeConstraint::__ANON__[:266]
0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeConstraint::::__ANON__[:26]Moose::Meta::TypeConstraint::__ANON__[:26]
0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeConstraint::::__ANON__[:279]Moose::Meta::TypeConstraint::__ANON__[:279]
0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeConstraint::::assert_validMoose::Meta::TypeConstraint::assert_valid
0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeConstraint::::get_messageMoose::Meta::TypeConstraint::get_message
0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeConstraint::::parentsMoose::Meta::TypeConstraint::parents
0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeConstraint::::validateMoose::Meta::TypeConstraint::validate

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

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  |
2 |  |  |  |  | package Moose::Meta::TypeConstraint;
3 |  |  |  |  |
4 | 3 | 20µs | 2 | 20µs | # spent 17µs (14+3) within Moose::Meta::TypeConstraint::BEGIN@4 which was called # once (14µs+3µs) by Moose::BEGIN@19 at line 4 use strict; # spent 17µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@4 # spent 3µs making 1 call to strict::import
5 | 3 | 25µs | 2 | 26µs | # spent 16µs (7+10) within Moose::Meta::TypeConstraint::BEGIN@5 which was called # once (7µs+10µs) by Moose::BEGIN@19 at line 5 use warnings; # spent 16µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@5 # spent 10µs making 1 call to warnings::import
6 | 3 | 120µs | 2 | 686µs | # spent 587µs (377+210) within Moose::Meta::TypeConstraint::BEGIN@6 which was called # once (377µs+210µs) by Moose::BEGIN@19 at line 6 use metaclass; # spent 587µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@6 # spent 99µs making 1 call to metaclass::import
7 |  |  |  |  |
8 | 933 | 2.71ms | 933 | 1.49ms | # spent 56µs (9+48) within Moose::Meta::TypeConstraint::BEGIN@8 which was called # once (9µs+48µs) by Moose::BEGIN@19 at line 9 # spent 4.65ms (3.16+1.49) within Moose::Meta::TypeConstraint::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Meta/TypeConstraint.pm:8] which was called 933 times, avg 5µs/call: # 229 times (790µs+379µs) by SimpleDB::Class::Item::CORE:match or SimpleDB::Class::Item::stringify_values at line 623 of ../lib/SimpleDB/Class/Item.pm, avg 5µs/call # 112 times (406µs+200µs) by MooseX::Types::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types.pm:486] at line 479 of MooseX/Types.pm, avg 5µs/call # 86 times (325µs+159µs) by Moose::Util::TypeConstraints::find_or_parse_type_constraint at line 217 of Moose/Util/TypeConstraints.pm, avg 6µs/call # 86 times (300µs+117µs) by Moose::Meta::TypeConstraint::Registry::add_type_constraint at line 47 of Moose/Meta/TypeConstraint/Registry.pm, avg 5µs/call # 82 times (222µs+100µs) by Moose::Util::TypeConstraints::find_or_create_isa_type_constraint at line 203 of Moose/Util/TypeConstraints.pm, avg 4µs/call # 61 times (222µs+97µs) by Moose::Meta::Method::Accessor::_eval_code at line 26 of Moose/Meta/Method/Accessor.pm, avg 5µs/call # 54 times (164µs+77µs) by MooseX::Types::TypeDecorator::new at line 69 of MooseX/Types/TypeDecorator.pm, avg 4µs/call # 54 times (143µs+65µs) by Moose::Meta::TypeConstraint::equals at line 134, avg 4µs/call # 53 times (139µs+63µs) by Moose::Meta::TypeConstraint::is_subtype_of at line 169, avg 4µs/call # 42 times (155µs+80µs) by MooseX::Types::Base::import at line 82 of MooseX/Types/Base.pm, avg 6µs/call # 19 times (48µs+21µs) by Moose::Util::TypeConstraints::_create_type_constraint at line 523 of Moose/Util/TypeConstraints.pm, avg 4µs/call # 18 times (131µs+77µs) by SimpleDB::Class::Item::CORE:match at line 584 of ../lib/SimpleDB/Class/Item.pm, avg 12µs/call # 17 times (54µs+22µs) by Moose::Meta::TypeConstraint::is_subtype_of at line 165, avg 4µs/call # 7 times (22µs+11µs) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 58 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 5µs/call # 6 times (16µs+7µs) by Moose::Util::TypeConstraints::find_or_create_type_constraint at line 175 of Moose/Util/TypeConstraints.pm, avg 4µs/call # 2 times (7µs+5µs) by Moose::Util::TypeConstraints::create_type_constraint_union at line 88 of Moose/Util/TypeConstraints.pm, avg 6µs/call # 2 times (6µ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, avg 5µs/call # 2 times (6µs+3µs) by Moose::Meta::TypeConstraint::is_a_type_of at line 157, avg 4µs/call # once (4µs+2µs) by Moose::init_meta at line 155 of Moose.pm use overload '""' => sub { shift->name }, # stringify to tc name # spent 1.49ms making 933 calls to Moose::Meta::TypeConstraint::name, avg 2µs/call
9 | 3 | 26µs | 2 | 104µs | fallback => 1; # spent 56µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@8 # spent 48µs making 1 call to overload::import
10 |  |  |  |  |
11 | 3 | 24µs | 2 | 62µs | # spent 35µs (7+28) within Moose::Meta::TypeConstraint::BEGIN@11 which was called # once (7µs+28µs) by Moose::BEGIN@19 at line 11 use Scalar::Util qw(blessed refaddr); # spent 35µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@11 # spent 28µs making 1 call to Exporter::import
12 | 3 | 23µs | 2 | 50µs | # spent 29µs (7+22) within Moose::Meta::TypeConstraint::BEGIN@12 which was called # once (7µs+22µs) by Moose::BEGIN@19 at line 12 use Sub::Name qw(subname); # spent 29µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@12 # spent 22µs making 1 call to Exporter::import
13 |  |  |  |  |
14 | 3 | 1.03ms | 2 | 84µs | # spent 45µs (6+39) within Moose::Meta::TypeConstraint::BEGIN@14 which was called # once (6µs+39µs) by Moose::BEGIN@19 at line 14 use base qw(Class::MOP::Object); # spent 45µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@14 # spent 39µs making 1 call to base::import
15 |  |  |  |  |
16 | 1 | 700ns |  |  | our $VERSION = '0.98';
17 | 1 | 14µs |  |  | $VERSION = eval $VERSION;
18 | 1 | 300ns |  |  | our $AUTHORITY = 'cpan:STEVAN';
19 |  |  |  |  |
20 | 1 | 3µs | 2 | 380µs | __PACKAGE__->meta->add_attribute('name' => (reader => 'name')); # spent 363µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 17µs making 1 call to Moose::Meta::TypeConstraint::meta
21 | 1 | 2µs | 2 | 411µs | __PACKAGE__->meta->add_attribute('parent' => ( # spent 401µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Moose::Meta::TypeConstraint::meta
22 |  |  |  |  | reader => 'parent',
23 |  |  |  |  | predicate => 'has_parent',
24 |  |  |  |  | ));
25 |  |  |  |  |
26 | 1 | 1µs |  |  | my $null_constraint = sub { 1 };
27 |  |  |  |  | __PACKAGE__->meta->add_attribute('constraint' => (
28 |  |  |  |  | reader => 'constraint',
29 |  |  |  |  | writer => '_set_constraint',
30 | 66 | 209µs |  |  | # spent 125µs within Moose::Meta::TypeConstraint::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Meta/TypeConstraint.pm:30] which was called 66 times, avg 2µs/call: # 28 times (66µs+0s) by Moose::Meta::TypeConstraint::Class::_new at line 35 of (eval 0)[Class/MOP/Method/Generated.pm:54] at line 54 of Class/MOP/Method/Generated.pm, avg 2µs/call # 22 times (31µs+0s) by Moose::Meta::TypeConstraint::Role::_new at line 32 of (eval 0)[Class/MOP/Method/Generated.pm:54] at line 54 of Class/MOP/Method/Generated.pm, avg 1µs/call # 7 times (11µs+0s) by Moose::Meta::TypeConstraint::Parameterized::_new at line 29 of (eval 0)[Class/MOP/Method/Generated.pm:54] at line 54 of Class/MOP/Method/Generated.pm, avg 2µs/call # 6 times (12µs+0s) by Moose::Meta::TypeConstraint::Parameterizable::_new at line 35 of (eval 0)[Class/MOP/Method/Generated.pm:54] at line 54 of Class/MOP/Method/Generated.pm, avg 2µs/call # 2 times (3µs+0s) by Moose::Meta::TypeConstraint::_new at line 26 of (eval 0)[Class/MOP/Method/Generated.pm:54] at line 54 of Class/MOP/Method/Generated.pm, avg 2µs/call # once (1µs+0s) by Moose::Meta::TypeConstraint::Union::_new at line 31 of (eval 0)[Class/MOP/Method/Generated.pm:54] at line 54 of Class/MOP/Method/Generated.pm default => sub { $null_constraint }
31 | 1 | 4µs | 2 | 424µs | )); # spent 414µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Moose::Meta::TypeConstraint::meta
32 | 1 | 2µs | 2 | 398µs | __PACKAGE__->meta->add_attribute('message' => ( # spent 388µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 10µs making 1 call to Moose::Meta::TypeConstraint::meta
33 |  |  |  |  | accessor => 'message',
34 |  |  |  |  | predicate => 'has_message'
35 |  |  |  |  | ));
36 | 1 | 2µs | 2 | 389µs | __PACKAGE__->meta->add_attribute('coercion' => ( # spent 378µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Moose::Meta::TypeConstraint::meta
37 |  |  |  |  | accessor => 'coercion',
38 |  |  |  |  | predicate => 'has_coercion'
39 |  |  |  |  | ));
40 |  |  |  |  |
41 | 1 | 2µs | 2 | 406µs | __PACKAGE__->meta->add_attribute('hand_optimized_type_constraint' => ( # spent 396µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Moose::Meta::TypeConstraint::meta
42 |  |  |  |  | init_arg => 'optimized',
43 |  |  |  |  | accessor => 'hand_optimized_type_constraint',
44 |  |  |  |  | predicate => 'has_hand_optimized_type_constraint',
45 |  |  |  |  | ));
46 |  |  |  |  |
47 |  |  |  |  | sub parents {
48 |  |  |  |  | my $self;
49 |  |  |  |  | $self->parent;
50 |  |  |  |  | }
51 |  |  |  |  |
52 |  |  |  |  | # private accessors
53 |  |  |  |  |
54 | 1 | 2µs | 2 | 394µs | __PACKAGE__->meta->add_attribute('compiled_type_constraint' => ( # spent 383µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Moose::Meta::TypeConstraint::meta
55 |  |  |  |  | accessor => '_compiled_type_constraint',
56 |  |  |  |  | predicate => '_has_compiled_type_constraint'
57 |  |  |  |  | ));
58 | 1 | 2µs | 2 | 265µs | __PACKAGE__->meta->add_attribute('package_defined_in' => ( # spent 254µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Moose::Meta::TypeConstraint::meta
59 |  |  |  |  | accessor => '_package_defined_in'
60 |  |  |  |  | ));
61 |  |  |  |  |
62 |  |  |  |  | # spent 7.78ms (728µs+7.05) within Moose::Meta::TypeConstraint::new which was called 41 times, avg 190µs/call: # 22 times (348µs+1.30ms) by Moose::Meta::TypeConstraint::create_child_type at line 298, avg 75µs/call # 7 times (148µs+4.37ms) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 69 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 645µs/call # 5 times (90µs+743µs) by Moose::Meta::TypeConstraint::Parameterized::create_child_type at line 67 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 167µs/call # once (20µs+142µs) by Moose::Meta::TypeConstraint::Union::new at line 27 of Moose/Meta/TypeConstraint/Union.pm # once (27µs+122µs) by Moose::Util::TypeConstraints::_create_type_constraint at line 533 of Moose/Util/TypeConstraints.pm # once (20µs+122µs) by Moose::Meta::TypeConstraint::Class::create_child_type at line 106 of Moose/Meta/TypeConstraint/Class.pm # once (27µs+106µs) by Moose::Meta::Attribute::BEGIN@18 at line 731 of Moose/Util/TypeConstraints.pm # once (19µs+88µs) by Moose::Meta::Attribute::BEGIN@18 at line 790 of Moose/Util/TypeConstraints.pm # once (15µs+28µs) by Moose::Meta::Attribute::BEGIN@18 at line 752 of Moose/Util/TypeConstraints.pm # once (14µs+27µs) by Moose::Meta::Attribute::BEGIN@18 at line 773 of Moose/Util/TypeConstraints.pm sub new {
63 | 287 | 573µs |  |  | my $class = shift;
64 |  |  |  |  | my ($first, @rest) = @_;
65 |  |  |  |  | my %args = ref $first ? %$first : $first ? ($first, @rest) : ();
66 | 1 | 22µs | 20 | 240µs | $args{name} = $args{name} ? "$args{name}" : "__ANON__"; # spent 240µs making 20 calls to MooseX::Types::TypeDecorator::__ANON__[MooseX/Types/TypeDecorator.pm:20], avg 12µs/call
67 |  |  |  |  |
68 |  |  |  |  | my $self = $class->_new(%args); # spent 347µs making 10 calls to Moose::Meta::TypeConstraint::Parameterizable::_new, avg 35µs/call # spent 345µs making 23 calls to Moose::Meta::TypeConstraint::_new, avg 15µs/call # spent 289µs making 7 calls to Moose::Meta::TypeConstraint::Parameterized::_new, avg 41µs/call # spent 109µs making 1 call to Moose::Meta::TypeConstraint::Union::_new
69 |  |  |  |  | $self->compile_type_constraint() # spent 4.07ms making 7 calls to Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint, avg 581µs/call # spent 1.58ms making 34 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 47µs/call # spent 70µs making 41 calls to Moose::Meta::TypeConstraint::_has_compiled_type_constraint, avg 2µs/call
70 |  |  |  |  | unless $self->_has_compiled_type_constraint;
71 |  |  |  |  | return $self;
72 |  |  |  |  | }
73 |  |  |  |  |
74 |  |  |  |  |
75 |  |  |  |  |
76 |  |  |  |  | # spent 60.2ms (3.10+57.1) within Moose::Meta::TypeConstraint::coerce which was called 431 times, avg 140µs/call: # 250 times (1.74ms+39.2ms) by Moose::Meta::Attribute::_coerce_and_verify at line 740 of Moose/Meta/Attribute.pm, avg 164µs/call # 112 times (889µs+5.93ms) by MooseX::Types::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types.pm:486] at line 480 of MooseX/Types.pm, avg 61µs/call # 40 times (236µs+771µs) by Foo::Domain::color or Foo::Domain::components or Foo::Domain::notes or Foo::Domain::parentId or Foo::Domain::properties or Foo::Domain::quantity or Foo::Domain::size or Foo::Domain::size_formatted or Foo::Domain::start_date at line 5 of generated method (unknown origin), avg 25µs/call # 25 times (158µs+586µs) by Foo::Domain::components or Foo::Domain::notes or Foo::Domain::properties or Foo::Domain::start_date at line 13 of generated method (unknown origin), avg 30µs/call # 4 times (74µs+10.7ms) by SimpleDB::Class::Item::parse_value at line 550 of ../lib/SimpleDB/Class/Item.pm, avg 2.69ms/call sub coerce {
77 | 1818 | 2.28ms |  |  | my $self = shift;
78 |  |  |  |  |
79 |  |  |  |  | my $coercion = $self->coercion; # spent 730µs making 431 calls to Moose::Meta::TypeConstraint::coercion, avg 2µs/call
80 |  |  |  |  |
81 |  |  |  |  | unless ($coercion) {
82 |  |  |  |  | require Moose;
83 |  |  |  |  | Moose->throw_error("Cannot coerce without a type coercion");
84 |  |  |  |  | }
85 |  |  |  |  |
86 |  |  |  |  | return $_[0] if $self->check($_[0]); # spent 12.5ms making 431 calls to Moose::Meta::TypeConstraint::check, avg 29µs/call
87 |  |  |  |  |
88 |  |  |  |  | return $coercion->coerce(@_); # spent 73.2ms making 94 calls to Moose::Meta::TypeCoercion::coerce, avg 778µs/call, recursion: max depth 1, time 28.9ms
89 |  |  |  |  | }
90 |  |  |  |  |
91 |  |  |  |  | # spent 20.4ms (5.56+14.8) within Moose::Meta::TypeConstraint::check which was called 831 times, avg 25µs/call: # 431 times (3.01ms+9.50ms) by Moose::Meta::TypeConstraint::coerce at line 86, avg 29µs/call # 258 times (1.58ms+3.05ms) by Moose::Meta::Attribute::verify_against_type_constraint at line 757 of Moose/Meta/Attribute.pm, avg 18µs/call # 112 times (693µs+1.66ms) by MooseX::Types::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types.pm:486] at line 483 of MooseX/Types.pm, avg 21µs/call # 27 times (237µs+577µs) by MooseX::Types::TypeDecorator::AUTOLOAD at line 199 of MooseX/Types/TypeDecorator.pm, avg 30µs/call # 2 times (18µs+10µs) by Moose::Meta::TypeConstraint::Union::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Meta/TypeConstraint/Union.pm:50] at line 47 of Moose/Meta/TypeConstraint/Union.pm, avg 14µs/call # once (23µs+20µs) by Class::MOP::Class::__ANON__::SERIAL::1::_add_class_attribute at line 21 of MooseX/AttributeHelpers/MethodProvider/Hash.pm sub check {
92 | 2493 | 4.38ms |  |  | my ($self, @args) = @_;
93 |  |  |  |  | my $constraint_subref = $self->_compiled_type_constraint; # spent 1.33ms making 831 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 2µs/call
94 |  |  |  |  | return $constraint_subref->(@args) ? 1 : undef; # spent 4.71ms making 440 calls to SimpleDB::Class::Types::SdbStr, avg 11µs/call # spent 4.67ms making 73 calls to SimpleDB::Class::Types::SdbInt, avg 64µs/call # spent 2.18ms making 99 calls to SimpleDB::Class::Types::SdbArrayRefOfStr, avg 22µs/call # spent 702µs making 61 calls to SimpleDB::Class::Types::SdbMediumStr, avg 12µs/call # spent 582µs making 65 calls to Moose::Meta::TypeConstraint::Class::__ANON__[Moose/Meta/TypeConstraint/Class.pm:38], avg 9µs/call # spent 483µs making 28 calls to SimpleDB::Class::Types::SdbIntAsStr, avg 17µs/call # spent 92µs making 59 calls to Moose::Util::TypeConstraints::OptimizedConstraints::HashRef, avg 2µs/call # spent 38µs making 2 calls to HashRef[Moose::Meta::Attribute], avg 19µs/call # spent 19µs making 2 calls to Moose::Util::TypeConstraints::OptimizedConstraints::ClassName, avg 10µs/call # spent 5µs making 2 calls to Moose::Util::TypeConstraints::OptimizedConstraints::Str, avg 2µs/call
95 |  |  |  |  | }
96 |  |  |  |  |
97 |  |  |  |  | sub validate {
98 |  |  |  |  | my ($self, $value) = @_;
99 |  |  |  |  | if ($self->_compiled_type_constraint->($value)) {
100 |  |  |  |  | return undef;
101 |  |  |  |  | }
102 |  |  |  |  | else {
103 |  |  |  |  | $self->get_message($value);
104 |  |  |  |  | }
105 |  |  |  |  | }
106 |  |  |  |  |
107 |  |  |  |  | sub assert_valid {
108 |  |  |  |  | my ($self, $value) = @_;
109 |  |  |  |  |
110 |  |  |  |  | my $error = $self->validate($value);
111 |  |  |  |  | return 1 if ! defined $error;
112 |  |  |  |  |
113 |  |  |  |  | require Moose;
114 |  |  |  |  | Moose->throw_error($error);
115 |  |  |  |  | }
116 |  |  |  |  |
117 |  |  |  |  | sub get_message {
118 |  |  |  |  | my ($self, $value) = @_;
119 |  |  |  |  | if (my $msg = $self->message) {
120 |  |  |  |  | local $_ = $value;
121 |  |  |  |  | return $msg->($value);
122 |  |  |  |  | }
123 |  |  |  |  | else {
124 |  |  |  |  | $value = (defined $value ? overload::StrVal($value) : 'undef');
125 |  |  |  |  | return "Validation failed for '" . $self->name . "' failed with value $value";
126 |  |  |  |  | }
127 |  |  |  |  | }
128 |  |  |  |  |
129 |  |  |  |  | ## type predicates ...
130 |  |  |  |  |
131 |  |  |  |  | # spent 1.54ms (782µs+759µs) within Moose::Meta::TypeConstraint::equals which was called 54 times, avg 29µs/call: # 53 times (770µs+746µs) by Moose::Meta::TypeConstraint::is_subtype_of at line 170, avg 29µs/call # once (13µs+13µs) by Moose::Meta::TypeConstraint::is_a_type_of at line 159 sub equals {
132 | 252 | 555µs |  |  | my ( $self, $type_or_name ) = @_;
133 |  |  |  |  |
134 | 1 | 17µs | 108 | 490µs | my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return; # spent 281µs making 54 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 5µs/call # spent 208µs making 54 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:8], avg 4µs/call
135 |  |  |  |  |
136 |  |  |  |  | return 1 if refaddr($self) == refaddr($other); # spent 44µs making 108 calls to Scalar::Util::refaddr, avg 407ns/call
137 |  |  |  |  |
138 |  |  |  |  | if ( $self->has_hand_optimized_type_constraint and $other->has_hand_optimized_type_constraint ) { # spent 77µs making 63 calls to Moose::Meta::TypeConstraint::has_hand_optimized_type_constraint, avg 1µs/call # spent 43µs making 36 calls to Moose::Meta::TypeConstraint::hand_optimized_type_constraint, avg 1µs/call
139 |  |  |  |  | return 1 if $self->hand_optimized_type_constraint == $other->hand_optimized_type_constraint;
140 |  |  |  |  | }
141 |  |  |  |  |
142 |  |  |  |  | return unless $self->constraint == $other->constraint; # spent 105µs making 90 calls to Moose::Meta::TypeConstraint::constraint, avg 1µs/call
143 |  |  |  |  |
144 |  |  |  |  | if ( $self->has_parent ) {
145 |  |  |  |  | return unless $other->has_parent;
146 |  |  |  |  | return unless $self->parent->equals( $other->parent );
147 |  |  |  |  | } else {
148 |  |  |  |  | return if $other->has_parent;
149 |  |  |  |  | }
150 |  |  |  |  |
151 |  |  |  |  | return 1;
152 |  |  |  |  | }
153 |  |  |  |  |
154 |  |  |  |  | # spent 164µs (34+130) within Moose::Meta::TypeConstraint::is_a_type_of which was called 2 times, avg 82µs/call: # 2 times (34µs+130µs) by MooseX::AttributeHelpers::Trait::Base::process_options_for_provides at line 69 of MooseX/AttributeHelpers/Trait/Base.pm, avg 82µs/call sub is_a_type_of {
155 | 6 | 19µs |  |  | my ($self, $type_or_name) = @_;
156 |  |  |  |  |
157 | 1 | 1µs | 4 | 43µs | my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return; # spent 34µs making 2 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 17µs/call # spent 9µs making 2 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:8], avg 4µs/call
158 |  |  |  |  |
159 |  |  |  |  | ($self->equals($type) || $self->is_subtype_of($type)); # spent 44µs making 1 call to Moose::Meta::TypeConstraint::is_subtype_of # spent 25µs making 1 call to Moose::Meta::TypeConstraint::equals # spent 18µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::equals
160 |  |  |  |  | }
161 |  |  |  |  |
162 |  |  |  |  | # spent 2.60ms (469µs+2.13) within Moose::Meta::TypeConstraint::is_subtype_of which was called 17 times, avg 153µs/call: # 16 times (458µs+2.10ms) by Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for at line 25 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 160µs/call # once (12µs+33µs) by Moose::Meta::TypeConstraint::is_a_type_of at line 159 sub is_subtype_of {
163 | 77 | 88µs |  |  | my ($self, $type_or_name) = @_;
164 |  |  |  |  |
165 | 1 | 6µs | 34 | 346µs | my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return; # spent 270µs making 17 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 16µs/call # spent 76µs making 17 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:8], avg 4µs/call
166 |  |  |  |  |
167 |  |  |  |  | my $current = $self;
168 |  |  |  |  |
169 | 98 | 95µs | 115 | 273µs | while (my $parent = $current->parent) { # spent 202µs making 53 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:8], avg 4µs/call # spent 71µs making 62 calls to Moose::Meta::TypeConstraint::parent, avg 1µs/call
170 | 1 | 97µs | 53 | 1.52ms | return 1 if $parent->equals($type); # spent 1.52ms making 53 calls to Moose::Meta::TypeConstraint::equals, avg 29µs/call
171 |  |  |  |  | $current = $parent;
172 |  |  |  |  | }
173 |  |  |  |  |
174 |  |  |  |  | return 0;
175 |  |  |  |  | }
176 |  |  |  |  |
177 |  |  |  |  | ## compiling the type constraint
178 |  |  |  |  |
179 |  |  |  |  | # spent 3.40ms (570µs+2.83) within Moose::Meta::TypeConstraint::compile_type_constraint which was called 91 times, avg 37µs/call: # 34 times (183µs+1.40ms) by Moose::Meta::TypeConstraint::new at line 69, avg 47µs/call # 28 times (211µs+526µs) by Moose::Meta::TypeConstraint::Class::new at line 27 of Moose/Meta/TypeConstraint/Class.pm, avg 26µs/call # 22 times (127µs+332µs) by Moose::Meta::TypeConstraint::Role::new at line 27 of Moose/Meta/TypeConstraint/Role.pm, avg 21µs/call # 7 times (49µs+574µs) by Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint at line 54 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 89µs/call sub compile_type_constraint {
180 | 182 | 458µs |  |  | my $self = shift;
181 |  |  |  |  | $self->_compiled_type_constraint($self->_actually_compile_type_constraint); # spent 2.61ms making 90 calls to Moose::Meta::TypeConstraint::_actually_compile_type_constraint, avg 29µs/call # spent 204µs making 91 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 2µs/call # spent 20µs making 1 call to Moose::Meta::TypeConstraint::Union::_actually_compile_type_constraint
182 |  |  |  |  | }
183 |  |  |  |  |
184 |  |  |  |  | ## type compilers ...
185 |  |  |  |  |
186 |  |  |  |  | # spent 2.61ms (681µs+1.93) within Moose::Meta::TypeConstraint::_actually_compile_type_constraint which was called 90 times, avg 29µs/call: # 90 times (681µs+1.93ms) by Moose::Meta::TypeConstraint::compile_type_constraint at line 181, avg 29µs/call sub _actually_compile_type_constraint {
187 | 253 | 520µs |  |  | my $self = shift;
188 |  |  |  |  |
189 |  |  |  |  | return $self->_compile_hand_optimized_type_constraint # spent 389µs making 66 calls to Moose::Meta::TypeConstraint::_compile_hand_optimized_type_constraint, avg 6µs/call # spent 165µs making 90 calls to Moose::Meta::TypeConstraint::has_hand_optimized_type_constraint, avg 2µs/call
190 |  |  |  |  | if $self->has_hand_optimized_type_constraint;
191 |  |  |  |  |
192 |  |  |  |  | my $check = $self->constraint; # spent 36µs making 24 calls to Moose::Meta::TypeConstraint::constraint, avg 1µs/call
193 |  |  |  |  | unless ( defined $check ) {
194 |  |  |  |  | require Moose;
195 |  |  |  |  | Moose->throw_error( "Could not compile type constraint '"
196 |  |  |  |  | . $self->name
197 |  |  |  |  | . "' because no constraint check" );
198 |  |  |  |  | }
199 |  |  |  |  |
200 |  |  |  |  | return $self->_compile_subtype($check) # spent 1.27ms making 23 calls to Moose::Meta::TypeConstraint::_compile_subtype, avg 55µs/call # spent 37µs making 24 calls to Moose::Meta::TypeConstraint::has_parent, avg 2µs/call
201 |  |  |  |  | if $self->has_parent;
202 |  |  |  |  |
203 |  |  |  |  | return $self->_compile_type($check); # spent 28µs making 1 call to Moose::Meta::TypeConstraint::_compile_type
204 |  |  |  |  | }
205 |  |  |  |  |
206 |  |  |  |  | # spent 389µs (311+78) within Moose::Meta::TypeConstraint::_compile_hand_optimized_type_constraint which was called 66 times, avg 6µs/call: # 66 times (311µs+78µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 189, avg 6µs/call sub _compile_hand_optimized_type_constraint {
207 | 264 | 254µs |  |  | my $self = shift;
208 |  |  |  |  |
209 |  |  |  |  | my $type_constraint = $self->hand_optimized_type_constraint; # spent 78µs making 66 calls to Moose::Meta::TypeConstraint::hand_optimized_type_constraint, avg 1µs/call
210 |  |  |  |  |
211 |  |  |  |  | unless ( ref $type_constraint ) {
212 |  |  |  |  | require Moose;
213 |  |  |  |  | Carp::confess ("Hand optimized type constraint for " . $self->name . " is not a code reference");
214 |  |  |  |  | Moose->throw_error("Hand optimized type constraint is not a code reference");
215 |  |  |  |  | }
216 |  |  |  |  |
217 |  |  |  |  | return $type_constraint;
218 |  |  |  |  | }
219 |  |  |  |  |
220 |  |  |  |  | # spent 1.27ms (555µs+720µs) within Moose::Meta::TypeConstraint::_compile_subtype which was called 23 times, avg 55µs/call: # 23 times (555µs+720µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 200, avg 55µs/call sub _compile_subtype {
221 | 138 | 119µs |  |  | my ($self, $check) = @_;
222 |  |  |  |  |
223 |  |  |  |  | # gather all the parent constraintss in order
224 |  |  |  |  | my @parents;
225 |  |  |  |  | my $optimized_parent;
226 |  |  |  |  | foreach my $parent ($self->_collect_all_parents) { # spent 530µs making 23 calls to Moose::Meta::TypeConstraint::_collect_all_parents, avg 23µs/call
227 |  |  |  |  | # if a parent is optimized, the optimized constraint already includes
228 |  |  |  |  | # all of its parents tcs, so we can break the loop
229 | 82 | 102µs | 32 | 43µs | if ($parent->has_hand_optimized_type_constraint) { # spent 43µs making 32 calls to Moose::Meta::TypeConstraint::has_hand_optimized_type_constraint, avg 1µs/call
230 |  |  |  |  | push @parents => $optimized_parent = $parent->hand_optimized_type_constraint; # spent 28µs making 18 calls to Moose::Meta::TypeConstraint::hand_optimized_type_constraint, avg 2µs/call
231 |  |  |  |  | last;
232 |  |  |  |  | }
233 |  |  |  |  | else {
234 |  |  |  |  | push @parents => $parent->constraint; # spent 15µs making 14 calls to Moose::Meta::TypeConstraint::constraint, avg 1µs/call
235 |  |  |  |  | }
236 |  |  |  |  | }
237 |  |  |  |  |
238 |  |  |  |  | @parents = grep { $_ != $null_constraint } reverse @parents;
239 |  |  |  |  |
240 | 43 | 126µs |  |  | unless ( @parents ) {
241 |  |  |  |  | return $self->_compile_type($check);
242 |  |  |  |  | } elsif( $optimized_parent and @parents == 1 ) {
243 |  |  |  |  | # the case of just one optimized parent is optimized to prevent
244 |  |  |  |  | # looping and the unnecessary localization
245 | 11 | 147µs |  |  | if ( $check == $null_constraint ) {
246 |  |  |  |  | return $optimized_parent;
247 |  |  |  |  | } else {
248 |  |  |  |  | return subname($self->name, sub {
249 | 3086 | 4.66ms | 848 | 5.48ms | return undef unless $optimized_parent->($_[0]); # spent 3.95ms making 88 calls to Moose::Util::TypeConstraints::OptimizedConstraints::Int, avg 45µs/call # spent 1.52ms making 758 calls to Moose::Util::TypeConstraints::OptimizedConstraints::Str, avg 2µs/call # spent 4µs making 2 calls to Moose::Util::TypeConstraints::OptimizedConstraints::HashRef, avg 2µs/call
250 |  |  |  |  | my (@args) = @_;
251 |  |  |  |  | local $_ = $args[0];
252 |  |  |  |  | $check->(@args); # spent 973µs making 571 calls to SimpleDB::Class::Types::__ANON__[../lib/SimpleDB/Class/Types.pm:89], avg 2µs/call # spent 391µs making 74 calls to SimpleDB::Class::Types::__ANON__[../lib/SimpleDB/Class/Types.pm:108], avg 5µs/call # spent 155µs making 28 calls to SimpleDB::Class::Types::__ANON__[../lib/SimpleDB/Class/Types.pm:112], avg 6µs/call # spent 142µs making 71 calls to SimpleDB::Class::Types::__ANON__[../lib/SimpleDB/Class/Types.pm:93], avg 2µs/call # spent 10µs making 2 calls to Moose::Util::TypeConstraints::__ANON__[Moose/Util/TypeConstraints.pm:770], avg 5µs/call
253 |  |  |  |  | }); # spent 43µs making 11 calls to Sub::Name::subname, avg 4µs/call # spent 19µs making 11 calls to Moose::Meta::TypeConstraint::name, avg 2µs/call
254 |  |  |  |  | }
255 |  |  |  |  | } else {
256 |  |  |  |  | # general case, check all the constraints, from the first parent to ourselves
257 |  |  |  |  | my @checks = @parents;
258 |  |  |  |  | push @checks, $check if $check != $null_constraint;
259 |  |  |  |  | return subname($self->name => sub {
260 | 747 | 649µs |  |  | my (@args) = @_;
261 |  |  |  |  | local $_ = $args[0];
262 |  |  |  |  | foreach my $check (@checks) {
263 | 370 | 737µs | 370 | 2.31ms | return undef unless $check->(@args); # spent 1.95ms making 154 calls to Moose::Util::TypeConstraints::__ANON__[Moose/Util/TypeConstraints.pm:749], avg 13µs/call # spent 259µs making 186 calls to Moose::Util::TypeConstraints::OptimizedConstraints::ArrayRef, avg 1µs/call # spent 44µs making 10 calls to Moose::Util::TypeConstraints::__ANON__[Moose/Util/TypeConstraints.pm:657], avg 4µs/call # spent 41µs making 15 calls to Moose::Util::TypeConstraints::__ANON__[Moose/Util/TypeConstraints.pm:650], avg 3µs/call # spent 20µs making 5 calls to Moose::Util::TypeConstraints::__ANON__[Moose/Util/TypeConstraints.pm:653], avg 4µs/call
264 |  |  |  |  | }
265 |  |  |  |  | return 1;
266 |  |  |  |  | }); # spent 26µs making 10 calls to Sub::Name::subname, avg 3µs/call # spent 15µs making 10 calls to Moose::Meta::TypeConstraint::name, avg 1µs/call
267 |  |  |  |  | }
268 |  |  |  |  | }
269 |  |  |  |  |
270 |  |  |  |  | # spent 28µs (14+14) within Moose::Meta::TypeConstraint::_compile_type which was called # once (14µs+14µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 203 sub _compile_type {
271 | 3 | 24µs |  |  | my ($self, $check) = @_;
272 |  |  |  |  |
273 |  |  |  |  | return $check if $check == $null_constraint; # Item, Any
274 |  |  |  |  |
275 |  |  |  |  | return subname($self->name => sub {
276 |  |  |  |  | my (@args) = @_;
277 |  |  |  |  | local $_ = $args[0];
278 |  |  |  |  | $check->(@args);
279 |  |  |  |  | }); # spent 12µs making 1 call to Sub::Name::subname # spent 2µs making 1 call to Moose::Meta::TypeConstraint::name
280 |  |  |  |  | }
281 |  |  |  |  |
282 |  |  |  |  | ## other utils ...
283 |  |  |  |  |
284 |  |  |  |  | # spent 530µs (386+144) within Moose::Meta::TypeConstraint::_collect_all_parents which was called 23 times, avg 23µs/call: # 23 times (386µs+144µs) by Moose::Meta::TypeConstraint::_compile_subtype at line 226, avg 23µs/call sub _collect_all_parents {
285 | 115 | 102µs |  |  | my $self = shift;
286 |  |  |  |  | my @parents;
287 |  |  |  |  | my $current = $self->parent; # spent 31µs making 23 calls to Moose::Meta::TypeConstraint::parent, avg 1µs/call
288 |  |  |  |  | while (defined $current) {
289 | 214 | 133µs |  |  | push @parents => $current;
290 |  |  |  |  | $current = $current->parent; # spent 113µs making 107 calls to Moose::Meta::TypeConstraint::parent, avg 1µs/call
291 |  |  |  |  | }
292 |  |  |  |  | return @parents;
293 |  |  |  |  | }
294 |  |  |  |  |
295 |  |  |  |  | # spent 1.78ms (130µs+1.65) within Moose::Meta::TypeConstraint::create_child_type which was called 22 times, avg 81µs/call: # 17 times (95µs+950µs) by Moose::Util::TypeConstraints::_create_type_constraint at line 523 of Moose/Util/TypeConstraints.pm, avg 62µs/call # 5 times (34µs+702µs) by MooseX::Types::TypeDecorator::AUTOLOAD at line 199 of MooseX/Types/TypeDecorator.pm, avg 147µs/call sub create_child_type {
296 | 66 | 119µs |  |  | my ($self, %opts) = @_;
297 |  |  |  |  | my $class = ref $self;
298 |  |  |  |  | return $class->new(%opts, parent => $self); # spent 1.65ms making 22 calls to Moose::Meta::TypeConstraint::new, avg 75µs/call
299 |  |  |  |  | }
300 |  |  |  |  |
301 | 1 | 25µs |  |  | 1;
302 |  |  |  |  |
303 |  |  |  |  | __END__
304 |  |  |  |  |
305 |  |  |  |  | =pod
306 |  |  |  |  |
307 |  |  |  |  | =head1 NAME
308 |  |  |  |  |
309 |  |  |  |  | Moose::Meta::TypeConstraint - The Moose Type Constraint metaclass
310 |  |  |  |  |
311 |  |  |  |  | =head1 DESCRIPTION
312 |  |  |  |  |
313 |  |  |  |  | This class represents a single type constraint. Moose's built-in type
314 |  |  |  |  | constraints, as well as constraints you define, are all stored in a
315 |  |  |  |  | L<Moose::Meta::TypeConstraint::Registry> object as objects of this
316 |  |  |  |  | class.
317 |  |  |  |  |
318 |  |  |  |  | =head1 INHERITANCE
319 |  |  |  |  |
320 |  |  |  |  | C<Moose::Meta::TypeConstraint> is a subclass of L<Class::MOP::Object>.
321 |  |  |  |  |
322 |  |  |  |  | =head1 METHODS
323 |  |  |  |  |
324 |  |  |  |  | =over 4
325 |  |  |  |  |
326 |  |  |  |  | =item B<< Moose::Meta::TypeConstraint->new(%options) >>
327 |  |  |  |  |
328 |  |  |  |  | This creates a new type constraint based on the provided C<%options>:
329 |  |  |  |  |
330 |  |  |  |  | =over 8
331 |  |  |  |  |
332 |  |  |  |  | =item * name
333 |  |  |  |  |
334 |  |  |  |  | The constraint name. If a name is not provided, it will be set to
335 |  |  |  |  | "__ANON__".
336 |  |  |  |  |
337 |  |  |  |  | =item * parent
338 |  |  |  |  |
339 |  |  |  |  | A C<Moose::Meta::TypeConstraint> object which is the parent type for
340 |  |  |  |  | the type being created. This is optional.
341 |  |  |  |  |
342 |  |  |  |  | =item * constraint
343 |  |  |  |  |
344 |  |  |  |  | This is the subroutine reference that implements the actual constraint
345 |  |  |  |  | check. This defaults to a subroutine which always returns true.
346 |  |  |  |  |
347 |  |  |  |  | =item * message
348 |  |  |  |  |
349 |  |  |  |  | A subroutine reference which is used to generate an error message when
350 |  |  |  |  | the constraint fails. This is optional.
351 |  |  |  |  |
352 |  |  |  |  | =item * coercion
353 |  |  |  |  |
354 |  |  |  |  | A L<Moose::Meta::TypeCoercion> object representing the coercions to
355 |  |  |  |  | the type. This is optional.
356 |  |  |  |  |
357 |  |  |  |  | =item * optimized
358 |  |  |  |  |
359 |  |  |  |  | This is a variant of the C<constraint> parameter that is somehow
360 |  |  |  |  | optimized. Typically, this means incorporating both the type's
361 |  |  |  |  | constraint and all of its parents' constraints into a single
362 |  |  |  |  | subroutine reference.
363 |  |  |  |  |
364 |  |  |  |  | =back
365 |  |  |  |  |
366 |  |  |  |  | =item B<< $constraint->equals($type_name_or_object) >>
367 |  |  |  |  |
368 |  |  |  |  | Returns true if the supplied name or type object is the same as the
369 |  |  |  |  | current type.
370 |  |  |  |  |
371 |  |  |  |  | =item B<< $constraint->is_subtype_of($type_name_or_object) >>
372 |  |  |  |  |
373 |  |  |  |  | Returns true if the supplied name or type object is a parent of the
374 |  |  |  |  | current type.
375 |  |  |  |  |
376 |  |  |  |  | =item B<< $constraint->is_a_type_of($type_name_or_object) >>
377 |  |  |  |  |
378 |  |  |  |  | Returns true if the given type is the same as the current type, or is
379 |  |  |  |  | a parent of the current type. This is a shortcut for checking
380 |  |  |  |  | C<equals> and C<is_subtype_of>.
381 |  |  |  |  |
382 |  |  |  |  | =item B<< $constraint->coerce($value) >>
383 |  |  |  |  |
384 |  |  |  |  | This will attempt to coerce the value to the type. If the type does
385 |  |  |  |  | have any defined coercions this will throw an error.
386 |  |  |  |  |
387 |  |  |  |  | =item B<< $constraint->check($value) >>
388 |  |  |  |  |
389 |  |  |  |  | Returns true if the given value passes the constraint for the type.
390 |  |  |  |  |
391 |  |  |  |  | =item B<< $constraint->validate($value) >>
392 |  |  |  |  |
393 |  |  |  |  | This is similar to C<check>. However, if the type I<is valid> then the
394 |  |  |  |  | method returns an explicit C<undef>. If the type is not valid, we call
395 |  |  |  |  | C<< $self->get_message($value) >> internally to generate an error
396 |  |  |  |  | message.
397 |  |  |  |  |
398 |  |  |  |  | =item B<< $constraint->assert_valid($value) >>
399 |  |  |  |  |
400 |  |  |  |  | Like C<check> and C<validate>, this method checks whether C<$value> is
401 |  |  |  |  | valid under the constraint. If it is, it will return true. If it is not,
402 |  |  |  |  | an exception will be thrown with the results of
403 |  |  |  |  | C<< $self->get_message($value) >>.
404 |  |  |  |  |
405 |  |  |  |  | =item B<< $constraint->name >>
406 |  |  |  |  |
407 |  |  |  |  | Returns the type's name, as provided to the constructor.
408 |  |  |  |  |
409 |  |  |  |  | =item B<< $constraint->parent >>
410 |  |  |  |  |
411 |  |  |  |  | Returns the type's parent, as provided to the constructor, if any.
412 |  |  |  |  |
413 |  |  |  |  | =item B<< $constraint->has_parent >>
414 |  |  |  |  |
415 |  |  |  |  | Returns true if the type has a parent type.
416 |  |  |  |  |
417 |  |  |  |  | =item B<< $constraint->parents >>
418 |  |  |  |  |
419 |  |  |  |  | A synonym for C<parent>. This is useful for polymorphism with types
420 |  |  |  |  | that can have more than one parent.
421 |  |  |  |  |
422 |  |  |  |  | =item B<< $constraint->constraint >>
423 |  |  |  |  |
424 |  |  |  |  | Returns the type's constraint, as provided to the constructor.
425 |  |  |  |  |
426 |  |  |  |  | =item B<< $constraint->get_message($value) >>
427 |  |  |  |  |
428 |  |  |  |  | This generates a method for the given value. If the type does not have
429 |  |  |  |  | an explicit message, we generate a default message.
430 |  |  |  |  |
431 |  |  |  |  | =item B<< $constraint->has_message >>
432 |  |  |  |  |
433 |  |  |  |  | Returns true if the type has a message.
434 |  |  |  |  |
435 |  |  |  |  | =item B<< $constraint->message >>
436 |  |  |  |  |
437 |  |  |  |  | Returns the type's message as a subroutine reference.
438 |  |  |  |  |
439 |  |  |  |  | =item B<< $constraint->coercion >>
440 |  |  |  |  |
441 |  |  |  |  | Returns the type's L<Moose::Meta::TypeCoercion> object, if one
442 |  |  |  |  | exists.
443 |  |  |  |  |
444 |  |  |  |  | =item B<< $constraint->has_coercion >>
445 |  |  |  |  |
446 |  |  |  |  | Returns true if the type has a coercion.
447 |  |  |  |  |
448 |  |  |  |  | =item B<< $constraint->hand_optimized_type_constraint >>
449 |  |  |  |  |
450 |  |  |  |  | Returns the type's hand optimized constraint, as provided to the
451 |  |  |  |  | constructor via the C<optimized> option.
452 |  |  |  |  |
453 |  |  |  |  | =item B<< $constraint->has_hand_optimized_type_constraint >>
454 |  |  |  |  |
455 |  |  |  |  | Returns true if the type has an optimized constraint.
456 |  |  |  |  |
457 |  |  |  |  | =item B<< $constraint->create_child_type(%options) >>
458 |  |  |  |  |
459 |  |  |  |  | This returns a new type constraint of the same class using the
460 |  |  |  |  | provided C<%options>. The C<parent> option will be the current type.
461 |  |  |  |  |
462 |  |  |  |  | This method exists so that subclasses of this class can override this
463 |  |  |  |  | behavior and change how child types are created.
464 |  |  |  |  |
465 |  |  |  |  | =back
466 |  |  |  |  |
467 |  |  |  |  | =head1 BUGS
468 |  |  |  |  |
469 |  |  |  |  | See L<Moose/BUGS> for details on reporting bugs.
470 |  |  |  |  |
471 |  |  |  |  | =head1 AUTHOR
472 |  |  |  |  |
473 |  |  |  |  | Stevan Little E<lt>stevan@iinteractive.comE<gt>
474 |  |  |  |  |
475 |  |  |  |  | =head1 COPYRIGHT AND LICENSE
476 |  |  |  |  |
477 |  |  |  |  | Copyright 2006-2010 by Infinity Interactive, Inc.
478 |  |  |  |  |
479 |  |  |  |  | L<http://www.iinteractive.com>
480 |  |  |  |  |
481 |  |  |  |  | This library is free software; you can redistribute it and/or modify
482 |  |  |  |  | it under the same terms as Perl itself.
483 |  |  |  |  |
484 |  |  |  |  | =cut