use strict;
use warnings;
+use Carp 'confess';
+
+our $VERSION = '0.02';
+
use base 'Class::MOP::Class';
+sub construct_instance {
+ my ($class, %params) = @_;
+ my $instance = $params{'__INSTANCE__'} || {};
+ foreach my $attr ($class->compute_all_applicable_attributes()) {
+ my $init_arg = $attr->init_arg();
+ # try to fetch the init arg from the %params ...
+ my $val;
+ $val = $params{$init_arg} if exists $params{$init_arg};
+ # if nothing was in the %params, we can use the
+ # attribute's default value (if it has one)
+ $val ||= $attr->default($instance) if $attr->has_default;
+ if (defined $val) {
+ if ($attr->has_type_constraint) {
+ if ($attr->should_coerce && $attr->type_constraint->has_coercion) {
+ $val = $attr->type_constraint->coercion->coerce($val);
+ }
+ (defined($attr->type_constraint->check($val)))
+ || confess "Attribute (" . $attr->name . ") does not pass the type contraint with '$val'";
+ }
+ }
+ $instance->{$attr->name} = $val;
+ }
+ return $instance;
+}
+
1;
__END__
=head1 NAME
-Moose::Meta::Class -
+Moose::Meta::Class - The Moose metaclass
=head1 SYNOPSIS
=head1 DESCRIPTION
+This is a subclass of L<Class::MOP::Class> with Moose specific
+extensions.
+
=head1 METHODS
=over 4
+=item B<construct_instance>
+
+=item B<mixed_in>
+
=back
=head1 BUGS
exception. If you find a bug please either email me, or add the bug
to cpan-RT.
-=head1 CODE COVERAGE
-
-I use L<Devel::Cover> to test the code coverage of my tests, below is the
-L<Devel::Cover> report on this module's test suite.
-
-=head1 ACKNOWLEDGEMENTS
-
=head1 AUTHOR
Stevan Little E<lt>stevan@iinteractive.comE<gt>