use BUILD's $args instead of %$self
Rafael Kitover
14 years ago
468 | 468 | ); |
469 | 469 | |
470 | 470 | sub BUILD { |
471 | my $self = shift; | |
471 | my ($self, $args) = @_; | |
472 | 472 | my $class = $self->_original_class_name; |
473 | 473 | my $schema_class = $self->schema_class; |
474 | 474 | |
504 | 504 | |
505 | 505 | $self->schema($self->composed_schema->clone); |
506 | 506 | |
507 | $self->_pass_options_to_schema; | |
507 | $self->_pass_options_to_schema($args); | |
508 | 508 | |
509 | 509 | $self->schema->storage_type($self->storage_type) |
510 | 510 | if $self->storage_type; |
620 | 620 | } |
621 | 621 | |
622 | 622 | sub _pass_options_to_schema { |
623 | my $self = shift; | |
624 | ||
625 | my @attributes = map $_->name, $self->meta->get_all_attributes; | |
623 | my ($self, $args) = @_; | |
624 | ||
625 | my @attributes = map { | |
626 | $_->init_arg || () | |
627 | } $self->meta->get_all_attributes; | |
628 | ||
626 | 629 | my %attributes; |
627 | 630 | @attributes{@attributes} = (); |
628 | 631 | |
629 | for my $opt (keys %$self) { | |
632 | for my $opt (keys %$args) { | |
630 | 633 | if (not exists $attributes{$opt}) { |
631 | 634 | next unless $self->schema->can($opt); |
632 | 635 | $self->schema->$opt($self->{$opt}); |