Changeset 75 in bookmarks for trunk


Ignore:
Timestamp:
04/11/14 11:03:53 (11 years ago)
Author:
peter
Message:
  • added a collection attribute to the Bookmark class
  • added an update() method to the Bookmark class that calls the collection->update() method, if the collection is set
  • Bookmarks::Controller::update_and_redirect() calls Bookmark::update()
Location:
trunk/lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Bookmark.pm

    r70 r75  
    1717has bookmark_uri => ( is => 'rw' ); 
    1818has exists => ( is => 'ro' ); 
     19has collection => ( is => 'ro' ); 
    1920 
    2021sub created { scalar localtime $_[0]->ctime } 
     
    4445} 
    4546 
     47sub update { 
     48    my $self = shift; 
     49    die "Not part of a collection; nowhere to write this bookmark" unless $self->collection; 
     50    return $self->collection->update($self); 
     51} 
     52 
    4653# module return 
    47541; 
  • trunk/lib/Bookmarks.pm

    r72 r75  
    6767    return Bookmark->new({ 
    6868        %$bookmark, 
    69         exists   => 1, 
    70         tags     => [ $self->get_tags({ uri => $bookmark->{uri} }) ], 
    71         base_uri => $self->base_uri, 
     69        exists     => 1, 
     70        tags       => [ $self->get_tags({ uri => $bookmark->{uri} }) ], 
     71        base_uri   => $self->base_uri, 
     72        collection => $self, 
    7273    }); 
    7374} 
     
    110111        push @resources, Bookmark->new({ 
    111112            %$resource, 
    112             tags     => [ $self->get_tags({ uri => $resource->{uri} }) ], 
    113             base_uri => $self->base_uri, 
     113            exists     => 1, 
     114            tags       => [ $self->get_tags({ uri => $resource->{uri} }) ], 
     115            base_uri   => $self->base_uri, 
     116            collection => $self, 
    114117        }); 
    115118    } 
     
    184187    my $bookmark = shift; 
    185188 
     189    #TODO: accept a pre-made Bookmark object in addition to a hash 
    186190    my $uri = $bookmark->{uri}; 
    187191    my $title = $bookmark->{title}; 
  • trunk/lib/Bookmarks/Controller.pm

    r74 r75  
    203203 
    204204        # write to the database 
    205         $self->bookmarks->update($bookmark); 
     205        $bookmark->update; 
    206206 
    207207        #TODO: not RESTful; proper response would be a 200 
Note: See TracChangeset for help on using the changeset viewer.