sub new {
my $class = shift;
- my %args = @_;
+ my %args;
+ if (scalar @_ == 1) {
+ if (defined $_[0]) {
+ (ref($_[0]) eq 'HASH')
+ || confess "Single parameters to new() must be a HASH ref";
+ %args = %{$_[0]};
+ }
+ }
+ else {
+ %args = @_;
+ }
+
my $instance = bless {}, $class;
- for my $attribute (values %{ $class->meta->get_attribute_map }) {
+ for my $attribute ($class->meta->compute_all_applicable_attributes) {
my $from = $attribute->init_arg;
my $key = $attribute->name;
my $default;
no strict 'refs';
- for my $class ($self->meta->linearized_isa) {
+ for my $class (reverse $self->meta->linearized_isa) {
my $code = *{ $class . '::BUILD' }{CODE}
or next;
$code->($self, @_);