From: moltar Date: Thu, 9 Jun 2011 00:25:25 +0000 (-0400) Subject: Improved formatting. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6e3c6029ca80748d228be8f2a0bd1e56c37932b0;p=dbsrgits%2FDBIx-Class-Schema-ResultSetAccessors.git Improved formatting. --- diff --git a/lib/DBIx/Class/Schema/ResultSetAccessors.pm b/lib/DBIx/Class/Schema/ResultSetAccessors.pm index b20df3e..63b741d 100644 --- a/lib/DBIx/Class/Schema/ResultSetAccessors.pm +++ b/lib/DBIx/Class/Schema/ResultSetAccessors.pm @@ -10,19 +10,21 @@ use Sub::Name 'subname'; our $VERSION = 0.001000; sub register_source { - my $self = shift; + my $self = shift; my $moniker = $_[0]; - my $next = $self->next::method(@_); + my $next = $self->next::method(@_); + my $schema = ref($self) || $self; + + my $accessor_name = + exists $self->resultset_accessor_map->{$moniker} + ? $self->resultset_accessor_map->{$moniker} + : $self->resultset_accessor_name($moniker); - my $schema = ref($self) || $self; - my $accessor_name = exists $self->resultset_accessor_map->{$moniker} - ? $self->resultset_accessor_map->{$moniker} - : $self->resultset_accessor_name($moniker); if ($schema->can($accessor_name)) { $self->throw_exception( "Can't create ResultSet accessor '$accessor_name'. " . "Schema method with the same name already exists. " . - "Try overloading the name in resultset_accessor_map." + "Try overloading the name via resultset_accessor_map." ); } @@ -37,7 +39,7 @@ sub register_source { } sub resultset_accessor_map { - return {}; + {} } sub resultset_accessor_name { @@ -49,11 +51,10 @@ sub resultset_accessor_name { } sub pluralize_resultset_accessor_name { - my $self = shift; - my $original = shift or return; + my ($self, $original) = @_; - return join q{_}, split /\s+/, - Lingua::EN::Inflect::Phrase::to_PL(join q{ }, split /_/, $original); + return join ' ', split /\s+/, + Lingua::EN::Inflect::Phrase::to_PL(join ' ', split /_/, $original); } 1; # eof