improve Moose ResultSet example in SchemaProxy
[catagits/Catalyst-Model-DBIC-Schema.git] / lib / Catalyst / TraitFor / Model / DBIC / Schema / SchemaProxy.pm
index 0f97e97..490671a 100644 (file)
@@ -72,8 +72,16 @@ Or, if you prefer L<Moose>:
     use MooseX::ClassAttribute;
     extends 'DBIx::Class::ResultSet';
 
+    sub BUILDARGS { $_[2] } # important
+
     class_has rs_config_key1 => (is => 'rw', default => 'default_value');
 
+    ...
+
+    __PACKAGE__->meta->make_immutable;
+
+    1;
+
 In your catalyst config, use the generated Model name as the config key, e.g.:
 
     <Model::DB::Users>
@@ -165,19 +173,10 @@ sub _pass_options_to_schema {
 sub _pass_options_to_resultset {
     my ($self, $source, $args) = @_;
 
-    my @attributes = map {
-        $_->init_arg || ()
-    } $self->meta->get_all_attributes;
-
-    my %attributes;
-    @attributes{@attributes} = ();
-
     for my $opt (keys %$args) {
-        if (not exists $attributes{$opt}) {
-            my $rs_class = $self->schema->source($source)->resultset_class;
-            next unless $rs_class->can($opt);
-            $rs_class->$opt($args->{$opt});
-        }
+        my $rs_class = $self->schema->source($source)->resultset_class;
+        next unless $rs_class->can($opt);
+        $rs_class->$opt($args->{$opt});
     }
 }