From: Stevan Little Date: Tue, 21 Mar 2006 02:02:13 +0000 (+0000) Subject: cleaning up X-Git-Tag: 0_05~74 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2ca63f5d951fd87ddb7a8075a2a7a00f9da15ad1;p=gitmo%2FMoose.git cleaning up --- diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index d2fc8b1..f0978e6 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -11,21 +11,16 @@ our $VERSION = '0.02'; use base 'Class::MOP::Attribute'; -__PACKAGE__->meta->add_attribute('coerce' => ( - reader => 'coerce', - predicate => { 'has_coercion' => sub { $_[0]->coerce() ? 1 : 0 } } -)); - -__PACKAGE__->meta->add_attribute('weak_ref' => ( - reader => 'weak_ref', - predicate => { 'has_weak_ref' => sub { $_[0]->weak_ref() ? 1 : 0 } } -)); - +__PACKAGE__->meta->add_attribute('coerce' => (reader => 'coerce')); +__PACKAGE__->meta->add_attribute('weak_ref' => (reader => 'weak_ref')); __PACKAGE__->meta->add_attribute('type_constraint' => ( reader => 'type_constraint', predicate => 'has_type_constraint', )); +sub has_coercion { (shift)->coerce() ? 1 : 0 } +sub has_weak_ref { (shift)->weak_ref() ? 1 : 0 } + __PACKAGE__->meta->add_before_method_modifier('new' => sub { my (undef, undef, %options) = @_; if (exists $options{coerce} && $options{coerce}) { diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index b37e824..06390c3 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -11,6 +11,7 @@ use Scalar::Util 'blessed'; our $VERSION = '0.02'; use Moose::Meta::TypeConstraint; +use Moose::Meta::TypeCoercion; sub import { shift;