[Catalyst-commits] r13095 - Catalyst-Authentication-Store-DBIx-Class/trunk/lib/Catalyst/Authentication/Store/DBIx/Class

rafl at dev.catalyst.perl.org rafl at dev.catalyst.perl.org
Mon Mar 29 00:46:29 GMT 2010


Author: rafl
Date: 2010-03-29 01:46:29 +0100 (Mon, 29 Mar 2010)
New Revision: 13095

Modified:
   Catalyst-Authentication-Store-DBIx-Class/trunk/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm
Log:
use style;

Modified: Catalyst-Authentication-Store-DBIx-Class/trunk/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm
===================================================================
--- Catalyst-Authentication-Store-DBIx-Class/trunk/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm	2010-03-29 00:37:31 UTC (rev 13094)
+++ Catalyst-Authentication-Store-DBIx-Class/trunk/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm	2010-03-29 00:46:29 UTC (rev 13095)
@@ -13,9 +13,8 @@
 sub new {
     my ( $class, $config, $c) = @_;
 
-	if (!defined($config->{'user_model'})) {
-		$config->{'user_model'} = $config->{'user_class'};
-	}
+	$config->{user_model} = $config->{user_class}
+        unless defined $config->{user_model};
 
     my $self = {
         resultset => $c->model($config->{'user_model'}),
@@ -26,20 +25,22 @@
 
     bless $self, $class;
 
+    Catalyst::Exception->throw(
+        "\$c->model('${ \$self->config->{user_model} }') did not return a resultset."
+          . " Did you set user_model correctly?"
+    ) unless $self->{resultset};
 
-
-    if (not $self->{'resultset'}) {
-        Catalyst::Exception->throw("\$c->model('${ \$self->config->{user_model} }') did not return a resultset. Did you set user_model correctly?");
-    }
-
     $self->config->{'id_field'} = [$self->{'resultset'}->result_source->primary_columns]
         unless exists $self->config->{'id_field'};
 
     $self->config->{'id_field'} = [$self->config->{'id_field'}]
         unless ref $self->config->{'id_field'} eq 'ARRAY';
 
-    Catalyst::Exception->throw("id_field set to " . join(q{,} => @{ $self->config->{'id_field'} }) . " but user table has no column by that name!")
-        unless all { $self->{'resultset'}->result_source->has_column($_) } @{ $self->config->{'id_field'} };
+    Catalyst::Exception->throw(
+        "id_field set to "
+          . join(q{,} => @{ $self->config->{'id_field'} })
+          . " but user table has no column by that name!"
+    ) unless all { $self->{'resultset'}->result_source->has_column($_) } @{ $self->config->{'id_field'} };
 
     ## if we have lazyloading turned on - we should not query the DB unless something gets read.
     ## that's the idea anyway - still have to work out how to manage that - so for now we always force
@@ -89,7 +90,12 @@
         if (keys %{$searchargs}) {
             $self->_user($self->resultset->search($searchargs)->first);
         } else {
-            Catalyst::Exception->throw("Failed to load user data.  You passed [" . join(',', keys %{$authinfo}) . "] to authenticate() but your user source (" .  $self->config->{'user_model'} . ") only has these columns: [" . join( ",", $self->resultset->result_source->columns ) . "]   Check your authenticate() call.");
+            Catalyst::Exception->throw(
+                "Failed to load user data.  You passed [" . join(',', keys %{$authinfo}) . "]"
+                  . " to authenticate() but your user source (" .  $self->config->{'user_model'} . ")"
+                  . " only has these columns: [" . join( ",", $self->resultset->result_source->columns ) . "]"
+                  . "   Check your authenticate() call."
+            );
         }
     }
 
@@ -130,7 +136,11 @@
     } elsif (exists($self->config->{'role_relation'})) {
         my $relation = $self->config->{'role_relation'};
         if ($self->_user->$relation->result_source->has_column($self->config->{'role_field'})) {
-            @roles = map { $_->get_column($self->config->{'role_field'}) } $self->_user->$relation->search(undef, { columns => [ $self->config->{'role_field'}]})->all();
+            @roles = map {
+                $_->get_column($self->config->{role_field})
+            } $self->_user->$relation->search(undef, {
+                columns => [ $self->config->{role_field} ]
+            })->all;
             $self->_roles(\@roles);
         } else {
             Catalyst::Exception->throw("role table does not have a column called " . $self->config->{'role_field'});




More information about the Catalyst-commits mailing list