X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FController%2FDBIC%2FAPI%2FStoredResultSource.pm;h=a6c301c9d3b41b5e85599658074e2ea484aa4f30;hb=362e979fc3524f787217bbd65863f8a19a4133f8;hp=3fc3cf4104be2ae9b63a9ecb892c49c6d3e5c844;hpb=d273984026646e5b57c052deef3fcb9121122060;p=catagits%2FCatalyst-Controller-DBIC-API.git diff --git a/lib/Catalyst/Controller/DBIC/API/StoredResultSource.pm b/lib/Catalyst/Controller/DBIC/API/StoredResultSource.pm index 3fc3cf4..a6c301c 100644 --- a/lib/Catalyst/Controller/DBIC/API/StoredResultSource.pm +++ b/lib/Catalyst/Controller/DBIC/API/StoredResultSource.pm @@ -1,5 +1,5 @@ package Catalyst::Controller::DBIC::API::StoredResultSource; -#ABSTRACT: Provides acessors for static resources +#ABSTRACT: Provides accessors for static resources use Moose::Role; use MooseX::Types::Moose(':all'); @@ -17,40 +17,34 @@ class is the name of the class that is the model for this controller has 'class' => ( is => 'ro', isa => Str, writer => '_set_class' ); -=attribute_public stored_result_source is: ro, isa: L +=attribute_public result_class is: ro, isa: Str -This is the result source for the controller +result_class is the name of the resultset class that is the model for this controller =cut -has 'stored_result_source' => -( - is => 'ro', - isa => ResultSource, - lazy_build => 1, -); +has 'result_class' => ( is => 'ro', isa => Str, default => 'DBIx::Class::ResultClass::HashRefInflator' ); -=attribute_public stored_model is: ro, isa: L +=method_public stored_result_source -This is the model for the controller +This is the result source for the controller =cut -has 'stored_model' => -( - is => 'ro', - isa => Model, - lazy_build => 1, -); - -sub _build_stored_model -{ - return $_[0]->_application->model($_[0]->class); +sub stored_result_source +{ + return shift->stored_model->result_source; } -sub _build_stored_result_source +=method_public stored_model + +This is the model for the controller + +=cut + +sub stored_model { - return shift->stored_model->result_source(); + return $_[0]->_application->model($_[0]->class); } =method_public check_has_column @@ -75,7 +69,7 @@ check_has_relation meticulously delves into the result sources relationships to sub check_has_relation { my ($self, $rel, $other, $nest, $static) = @_; - + $nest ||= $self->stored_result_source; if(HashRef->check($other)) @@ -99,14 +93,14 @@ sub check_has_relation =method_public check_column_relation -Convenience method to first check if the provided argument is a valid relation (if it is a HashRef) or column. +Convenience method to first check if the provided argument is a valid relation (if it is a HashRef) or column. =cut sub check_column_relation { my ($self, $col_rel, $static) = @_; - + if(HashRef->check($col_rel)) { try