Changeset 88 in bookmarks for trunk/lib/Bookmarks


Ignore:
Timestamp:
06/04/15 22:00:25 (9 years ago)
Author:
peter
Message:

Better separation of the model for searching and the web app controller/representation layer

  • renamed Bookmarks::get_bookmarks() to search()
  • Bookmarks::search() now returns a Bookmarks::Search object instead of a Bookmarks::List
  • search results now reside in the Bookmarks::Search class
Location:
trunk/lib/Bookmarks
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Bookmarks/Controller.pm

    r75 r88  
    77use JSON; 
    88use Bookmarks; 
     9use Bookmarks::List; 
    910use URI; 
    1011use Template; 
     
    8384    my $offset = $self->request->param('offset'); 
    8485 
    85     my $list = $self->bookmarks->get_bookmarks({ 
    86         query  => $query, 
    87         tags   => \@tags, 
    88         limit  => $limit, 
    89         offset => $offset, 
     86    my $list = Bookmarks::List->new({ 
     87        bookmarks => $self->bookmarks, 
     88        search    => $self->bookmarks->search({ 
     89            query  => $query, 
     90            tags   => \@tags, 
     91            limit  => $limit, 
     92            offset => $offset, 
     93        }), 
    9094    }); 
    9195 
     
    104108 
    105109    # construct a feed from the most recent 12 bookmarks 
    106     my $list = $self->bookmarks->get_bookmarks({ query => $query, tags => \@tags, limit => 12 }); 
     110    my $list = Bookmarks::List->new({ 
     111        bookmarks => $self->bookmarks, 
     112        search    => $self->bookmarks->search({ query => $query, tags => \@tags, limit => 12 }), 
     113    }); 
    107114    return $list->as_atom; 
    108115} 
  • trunk/lib/Bookmarks/List.pm

    r71 r88  
    1313    is => 'ro', 
    1414    isa => 'Bookmarks::Search', 
    15     handles => [qw{query tags limit offset}], 
     15    handles => [qw{query tags limit offset results}], 
    1616); 
    17 has results => ( is => 'ro' ); 
    1817has title => ( 
    1918    is => 'ro', 
  • trunk/lib/Bookmarks/Search.pm

    r71 r88  
    1111has offset => (is => 'ro'); 
    1212 
     13has results => (is => 'rw', default => sub { [] }); 
     14 
    1315# module return 
    14161; 
Note: See TracChangeset for help on using the changeset viewer.