Permalink
Browse files

Fetch elements more efficiently.

  • Loading branch information...
1 parent fe4bd14 commit 5e94ba530f46e6d59aa28f04e6f85537daa1e19a @denny committed Dec 19, 2011
Showing with 15 additions and 13 deletions.
  1. +13 −11 lib/ShinyCMS/Controller/Shop.pm
  2. +2 −2 lib/ShinyCMS/Schema/Result/ShopItem.pm
@@ -7,6 +7,17 @@ use namespace::autoclean;
BEGIN { extends 'ShinyCMS::Controller'; }
+=head1 NAME
+
+ShinyCMS::Controller::Shop
+
+=head1 DESCRIPTION
+
+Controller for ShinyCMS shop.
+
+=cut
+
+
has items_per_page => (
isa => Int,
is => 'ro',
@@ -20,19 +31,8 @@ has can_like => (
);
-=head1 NAME
-
-ShinyCMS::Controller::Shop
-
-=head1 DESCRIPTION
-
-Controller for ShinyCMS shop.
-
=head1 METHODS
-=cut
-
-
=head2 index
For now, forwards to the category list.
@@ -315,13 +315,15 @@ sub get_item : Chained( 'base' ) : PathPart( 'item' ) : CaptureArgs( 1 ) {
code => $item_id,
hidden => 'false',
});
+ $c->stash->{ item }->{ elements } = $c->stash->{ item }->get_elements;
}
else {
# numeric identifier
$c->stash->{ item } = $c->model( 'DB::ShopItem' )->find({
id => $item_id,
hidden => 'false',
});
+ $c->stash->{ item }->{ elements } = $c->stash->{ item }->get_elements;
}
unless ( $c->stash->{ item } ) {
@@ -284,13 +284,13 @@ sub in_category {
}
-=head2 elements
+=head2 get_elements
Return a hash containing the associated elements
=cut
-sub elements {
+sub get_elements {
my( $self ) = @_;
my $elements = {};

0 comments on commit 5e94ba5

Please sign in to comment.