785ba5c61be733a49ee8d4e29e7c871c245d77b6
[gitmo/Moose.git] / lib / Moose / Meta / TypeConstraint.pm
1
2 package Moose::Meta::TypeConstraint;
3
4 use strict;
5 use warnings;
6 use metaclass;
7
8 Moose::Meta::TypeConstraint->meta->add_attribute(
9     Class::MOP::Attribute->new('name' => (
10         reader => 'name'
11     ))  
12 );
13
14 Moose::Meta::TypeConstraint->meta->add_attribute(
15     Class::MOP::Attribute->new('constraint_code' => (
16         reader => 'constraint_code'
17     ))  
18 );
19
20 Moose::Meta::TypeConstraint->meta->add_attribute(
21     Class::MOP::Attribute->new('coercion_code' => (
22         reader    => 'coercion_code',
23         writer    => 'set_coercion_code',        
24         predicate => 'has_coercion'
25     ))  
26 );
27
28 sub new    { (shift)->meta->new_object(@_)  }
29 sub check  { (shift)->constraint_code->(@_) }
30 sub coerce { (shift)->coercion_code->(@_)   }
31
32 1;
33
34 __END__
35
36 =pod
37
38 =head1 NAME
39
40 Moose::Meta::TypeConstraint - The Moose Type Constraint metaobject
41
42 =head1 SYNOPSIS
43
44 =head1 DESCRIPTION
45
46 =head1 METHODS
47
48 =over 4
49
50 =item B<meta>
51
52 =item B<new>
53
54 =item B<name>
55
56 =item B<check>
57
58 =item B<coerce>
59
60 =item B<coercion_code>
61
62 =item B<set_coercion_code>
63
64 =item B<constraint_code>
65
66 =item B<has_coercion>
67
68 =back
69
70 =head1 BUGS
71
72 All complex software has bugs lurking in it, and this module is no 
73 exception. If you find a bug please either email me, or add the bug
74 to cpan-RT.
75
76 =head1 AUTHOR
77
78 Stevan Little E<lt>stevan@iinteractive.comE<gt>
79
80 =head1 COPYRIGHT AND LICENSE
81
82 Copyright 2006 by Infinity Interactive, Inc.
83
84 L<http://www.iinteractive.com>
85
86 This library is free software; you can redistribute it and/or modify
87 it under the same terms as Perl itself. 
88
89 =cut