[Catalyst-commits] r9523 - in Catalyst-Controller-DBIC-API/1.001/trunk: lib/Catalyst/Controller/DBIC/API t/var

lukes at dev.catalyst.perl.org lukes at dev.catalyst.perl.org
Wed Mar 18 19:01:40 GMT 2009


Author: lukes
Date: 2009-03-18 19:01:40 +0000 (Wed, 18 Mar 2009)
New Revision: 9523

Modified:
   Catalyst-Controller-DBIC-API/1.001/trunk/lib/Catalyst/Controller/DBIC/API/Base.pm
   Catalyst-Controller-DBIC-API/1.001/trunk/t/var/DBIxClass.db
Log:
unscrewed indentation in base

Modified: Catalyst-Controller-DBIC-API/1.001/trunk/lib/Catalyst/Controller/DBIC/API/Base.pm
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/lib/Catalyst/Controller/DBIC/API/Base.pm	2009-03-18 17:33:37 UTC (rev 9522)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/lib/Catalyst/Controller/DBIC/API/Base.pm	2009-03-18 19:01:40 UTC (rev 9523)
@@ -1,5 +1,5 @@
-package # hide from PAUSE
-    Catalyst::Controller::DBIC::API::Base;
+package													# hide from PAUSE
+	Catalyst::Controller::DBIC::API::Base;
 
 use strict;
 use warnings;
@@ -9,22 +9,22 @@
 use JSON::Any;
 
 __PACKAGE__->mk_accessors(qw(
-  class create_requires update_requires update_allows $self->rs_stash_key create_allows list_count list_returns list_grouped_by list_search_exposes list_ordered_by rs_stash_key object_stash_key setup_list_method setup_dbic_args_method
-));
+															class create_requires update_requires update_allows $self->rs_stash_key create_allows list_count list_returns list_grouped_by list_search_exposes list_ordered_by rs_stash_key object_stash_key setup_list_method setup_dbic_args_method
+													));
 
 __PACKAGE__->config(
-  class => undef,
-  create_requires => [],
-  create_allows => [],
-  update_requires => [],
-  update_allows => [],
-  list_returns => [],
-  list_grouped_by => [],
-  list_search_exposes => [],
-  list_ordered_by => [],
-  list_count => undef,
-  object_stash_key => 'object',
-  rs_stash_key => 'class_rs'
+	class => undef,
+	create_requires => [],
+	create_allows => [],
+	update_requires => [],
+	update_allows => [],
+	list_returns => [],
+	list_grouped_by => [],
+	list_search_exposes => [],
+	list_ordered_by => [],
+	list_count => undef,
+	object_stash_key => 'object',
+	rs_stash_key => 'class_rs'
 );
 
 sub setup :Chained('specify.in.subclass.config') :CaptureArgs(0) :PathPart('specify.in.subclass.config') {
@@ -34,83 +34,83 @@
 }
 
 sub list :Private {
-  my ($self, $c) = @_;
+	my ($self, $c) = @_;
 
-  my ($params, $args) = @{$c->forward('generate_dbic_search_args')};
-  return if $self->get_errors($c);
+	my ($params, $args) = @{$c->forward('generate_dbic_search_args')};
+	return if $self->get_errors($c);
 
-  $c->stash->{$self->rs_stash_key} = $c->stash->{$self->rs_stash_key}->search($params, $args);
-  $c->forward('format_list');
+	$c->stash->{$self->rs_stash_key} = $c->stash->{$self->rs_stash_key}->search($params, $args);
+	$c->forward('format_list');
 }
 
 sub generate_dbic_search_args :Private {
-  my ($self, $c) = @_;
+	my ($self, $c) = @_;
 
-  my $req_params = (grep { ref $_ } values %{$c->req->params}) ? $c->req->params : $self->expand_hash($c->req->params);
-  if ( my $a = $self->setup_list_method ) {
-    my $setup_action = $self->action_for($a);
-    if ( defined $setup_action ) {
-      $c->forward("/$setup_action", [ $req_params ]);
-    } else {
-      $c->log->error("setup_list_method was configured, but action $a not found");
-    }
-  }
-  my $source = $c->stash->{$self->rs_stash_key}->result_source;
+	my $req_params = (grep { ref $_ } values %{$c->req->params}) ? $c->req->params : $self->expand_hash($c->req->params);
+	if ( my $a = $self->setup_list_method ) {
+		my $setup_action = $self->action_for($a);
+		if ( defined $setup_action ) {
+			$c->forward("/$setup_action", [ $req_params ]);
+		} else {
+			$c->log->error("setup_list_method was configured, but action $a not found");
+		}
+	}
+	my $source = $c->stash->{$self->rs_stash_key}->result_source;
 
-  my ($params, $join);
-  my $args = {};
-  if (exists $req_params->{search}
-      && ref $req_params->{search} eq 'HASH'
-   ) {
-    ($params, $join) = $self->_format_search($c, { params => $req_params->{search}, source => $source }) if ($req_params->{search});
-  }
-  # assume json if search wasn't expanded by expand_hash
-  else {
-    $params = exists $c->req->params->{search} ? JSON::Any->from_json($c->req->params->{search}) : undef;
-  }
-  $args->{group_by} = $req_params->{list_grouped_by} || ((scalar(@{$self->list_grouped_by})) ? $self->list_grouped_by : undef);
-  $args->{order_by} = $req_params->{list_ordered_by} || ((scalar(@{$self->list_ordered_by})) ? $self->list_ordered_by : undef);
-  $args->{rows} = $req_params->{list_count} || $self->list_count;
-  $args->{page} = $req_params->{list_page};
-  if ($args->{page}) {
-    unless ($args->{page} =~ /^\d+$/xms) {
-      $self->push_error($c, { message => "list_page must be numeric" });
-    }
-  }
-  if ($args->{rows}) {
-    unless ($args->{rows} =~ /^\d+$/xms) {
-      $self->push_error($c, { message => "list_count must be numeric" });
-    }
-  }
-  if ($args->{page} && !$args->{rows}) {
-    $self->push_error($c, { message => "list_page can only be used with list_count" });
-  }
-  $args->{select} = $req_params->{list_returns} || ((scalar(@{$self->list_returns})) ? $self->list_returns : undef);
+	my ($params, $join);
+	my $args = {};
+	if (exists $req_params->{search}
+				&& ref $req_params->{search} eq 'HASH'
+			) {
+		($params, $join) = $self->_format_search($c, { params => $req_params->{search}, source => $source }) if ($req_params->{search});
+	}
+	# assume json if search wasn't expanded by expand_hash
+	else {
+		$params = exists $c->req->params->{search} ? JSON::Any->from_json($c->req->params->{search}) : undef;
+	}
+	$args->{group_by} = $req_params->{list_grouped_by} || ((scalar(@{$self->list_grouped_by})) ? $self->list_grouped_by : undef);
+	$args->{order_by} = $req_params->{list_ordered_by} || ((scalar(@{$self->list_ordered_by})) ? $self->list_ordered_by : undef);
+	$args->{rows} = $req_params->{list_count} || $self->list_count;
+	$args->{page} = $req_params->{list_page};
+	if ($args->{page}) {
+		unless ($args->{page} =~ /^\d+$/xms) {
+			$self->push_error($c, { message => "list_page must be numeric" });
+		}
+	}
+	if ($args->{rows}) {
+		unless ($args->{rows} =~ /^\d+$/xms) {
+			$self->push_error($c, { message => "list_count must be numeric" });
+		}
+	}
+	if ($args->{page} && !$args->{rows}) {
+		$self->push_error($c, { message => "list_page can only be used with list_count" });
+	}
+	$args->{select} = $req_params->{list_returns} || ((scalar(@{$self->list_returns})) ? $self->list_returns : undef);
 	if ($args->{select}) {
 		# make sure all columns have an alias to avoid ambiguous issues
 		$args->{select} = [map { ($_ =~ m/\./) ? $_ : "me.$_" } (ref $args->{select}) ? @{$args->{select}} : $args->{select}];
 	}
-  $args->{join} = $join;
-  if ( my $a = $self->setup_dbic_args_method ) {
-    my $format_action = $self->action_for($a);
-    if ( defined $format_action ) {
-      ($params, $args) = @{$c->forward("/$format_action", [ $params, $args ])};
-    } else {
-      $c->log->error("setup_dbic_args_method was configured, but action $a not found");
-    }
-  }
+	$args->{join} = $join;
+	if ( my $a = $self->setup_dbic_args_method ) {
+		my $format_action = $self->action_for($a);
+		if ( defined $format_action ) {
+			($params, $args) = @{$c->forward("/$format_action", [ $params, $args ])};
+		} else {
+			$c->log->error("setup_dbic_args_method was configured, but action $a not found");
+		}
+	}
 
-  return [$params, $args];
+	return [$params, $args];
 }
 
 sub _format_search {
-  my ($self, $c, $p) = @_;
-  my $params = $p->{params};
-  my $source = $p->{source};
-  my $base = $p->{base} || 'me';
+	my ($self, $c, $p) = @_;
+	my $params = $p->{params};
+	my $source = $p->{source};
+	my $base = $p->{base} || 'me';
 
-  my $join = {};
-  my %search_params;
+	my $join = {};
+	my %search_params;
 
 	# munge list_search_exposes into format that's easy to do with
 	my %valid = map { (ref $_) ? %{$_} : ($_ => 1) } @{$p->{_list_search_exposes} || $self->list_search_exposes};
@@ -143,21 +143,21 @@
 		}
 	}
 
-  # build up condition on root source
-  foreach my $column (@valid_cols) {
-    next unless (exists $params->{$column});
-    next if ($_rel_map{$column} && ref $params->{$column});
+	# build up condition on root source
+	foreach my $column (@valid_cols) {
+		next unless (exists $params->{$column});
+		next if ($_rel_map{$column} && ref $params->{$column});
 
 		if ($_source_col_map{$column}) {
 			$search_params{join('.', $base, $column)} = $params->{$column};
 		} else {
 			$search_params{$column} = $params->{$column};
 		}
-  }
+	}
 
-  # build up related conditions
+	# build up related conditions
 	foreach my $rel (@valid_rels) {    
-    next if ($search_params{join('.', $base, $rel)}); # if it's a condition on the base source, then it's can't also be a rel		
+		next if ($search_params{join('.', $base, $rel)}); # if it's a condition on the base source, then it's can't also be a rel		
 		next unless (exists $params->{$rel});
 		next unless (ref $params->{$rel});
 		my $rel_params;
@@ -168,13 +168,13 @@
 }
 
 sub format_list :Private {
-  my ($self, $c) = @_;
+	my ($self, $c) = @_;
 
-  # Create another result set here, so if someone looks at $self->rs_stash_key
-  # it still is what they expect (and not inflating to a hash ref)
-  my $rs = $c->stash->{$self->rs_stash_key}->search;
-  $rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
-  $c->stash->{response}->{list} = [ $rs->all ];
+	# Create another result set here, so if someone looks at $self->rs_stash_key
+	# it still is what they expect (and not inflating to a hash ref)
+	my $rs = $c->stash->{$self->rs_stash_key}->search;
+	$rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
+	$c->stash->{response}->{list} = [ $rs->all ];
 }
 
 sub create :Private {
@@ -199,7 +199,7 @@
 
 	$c->req->params($req_params);
 	die "no object to update (looking at " . $self->object_stash_key . ")"
-         unless ( defined $c->stash->{$self->object_stash_key} );
+		unless ( defined $c->stash->{$self->object_stash_key} );
 
 	unless (ref($c->stash->{update_allows} || $self->update_allows) eq 'ARRAY') {
 		die "update_allows must be an arrayref in config or stash";
@@ -208,7 +208,7 @@
 		die "class resultset not set";
 	}
 
-#	use Data::Dumper; $c->log->debug(Dumper(\%create_args));
+	#	use Data::Dumper; $c->log->debug(Dumper(\%create_args));
 	my $object = $c->stash->{$self->object_stash_key};
 	$self->validate_and_save_object($c, $object);
 }
@@ -224,15 +224,15 @@
 	my ($self, $c, $object) = @_;
 	my $params;
 	unless ($params = $self->validate($c, $object)) {
-        $c->log->debug("No value from validate, cowardly bailing out")
-            if $c->debug;
+		$c->log->debug("No value from validate, cowardly bailing out")
+			if $c->debug;
 		return;
 	}
 
-    if ( $c->debug ) {
-        $c->log->debug("Saving object: $object");
-        $c->log->_dump( $params );
-    }
+	if ( $c->debug ) {
+		$c->log->debug("Saving object: $object");
+		$c->log->_dump( $params );
+	}
 	return $self->save_object($c, $object, $params);
 }
 
@@ -278,7 +278,7 @@
 					# if not defined look for default
 					$value = $object->result_source
 						->column_info($key)
-					->{default_value};
+							->{default_value};
 					unless (defined $value) {
 						$self->push_error($c, { message => "No value supplied for ${key} and no default" });
 					}
@@ -298,7 +298,7 @@
 		}
 	}
 
-#	use Data::Dumper; $c->log->debug(Dumper(\%values));
+	#	use Data::Dumper; $c->log->debug(Dumper(\%values));
 	unless (keys %values || !$object->in_storage) {
 		$self->push_error($c, { message => "No valid keys passed" });
 	}
@@ -322,7 +322,7 @@
 		$object->set_columns($params);
 		$object->insert;
 	}
-  return $object;
+	return $object;
 }
 
 sub end :Private {
@@ -331,12 +331,11 @@
 	# check for errors
 	my $default_status;
 
-  # Check for errors caught elsewhere
+	# Check for errors caught elsewhere
 	if ( $c->res->status and $c->res->status != 200 ) {
 		$default_status = $c->res->status;
 		$c->stash->{response}->{success} = 'false';
-  }
-	elsif ($self->get_errors($c)) {
+	} elsif ($self->get_errors($c)) {
 		$c->stash->{response}->{messages} = $self->get_errors($c);
 		$c->stash->{response}->{success} = 'false';
 		$default_status = 400;
@@ -363,15 +362,15 @@
 }
 
 sub get_errors {
-  my ( $self, $c, $params ) = @_;
+	my ( $self, $c, $params ) = @_;
 
-  return $c->stash->{_dbic_crud_errors};
+	return $c->stash->{_dbic_crud_errors};
 }
 
 
 =head1 AUTHOR
 
-  Luke Saunders <luke.saunders at gmail.com>
+Luke Saunders <luke.saunders at gmail.com>
 
 =cut
 

Modified: Catalyst-Controller-DBIC-API/1.001/trunk/t/var/DBIxClass.db
===================================================================
(Binary files differ)




More information about the Catalyst-commits mailing list