2 package Moose::Meta::Class;
11 use base 'Class::MOP::Class';
13 sub construct_instance {
14 my ($class, %params) = @_;
16 foreach my $attr ($class->compute_all_applicable_attributes()) {
17 my $init_arg = $attr->init_arg();
18 # try to fetch the init arg from the %params ...
20 $val = $params{$init_arg} if exists $params{$init_arg};
21 # if nothing was in the %params, we can use the
22 # attribute's default value (if it has one)
23 $val ||= $attr->default($instance) if $attr->has_default;
24 if (defined $val && $attr->has_type_constraint) {
25 (defined $attr->type_constraint->($val))
26 || confess "Attribute (" . $attr->name . ") does not pass the type contraint";
28 $instance->{$attr->name} = $val;
51 =item B<construct_instance>
57 All complex software has bugs lurking in it, and this module is no
58 exception. If you find a bug please either email me, or add the bug
63 I use L<Devel::Cover> to test the code coverage of my tests, below is the
64 L<Devel::Cover> report on this module's test suite.
66 =head1 ACKNOWLEDGEMENTS
70 Stevan Little E<lt>stevan@iinteractive.comE<gt>
72 =head1 COPYRIGHT AND LICENSE
74 Copyright 2006 by Infinity Interactive, Inc.
76 L<http://www.iinteractive.com>
78 This library is free software; you can redistribute it and/or modify
79 it under the same terms as Perl itself.