Last change
on this file since 52 was
46,
checked in by peter, 11 years ago
|
- moved the update method from Bookmark to Bookmarks
- added a utility helper method _update_tags that is called by add and update in the Bookmarks class
|
File size:
852 bytes
|
Line | |
---|
1 | package Bookmark; |
---|
2 | |
---|
3 | use Moose; |
---|
4 | |
---|
5 | has id => ( is => 'ro' ); |
---|
6 | has uri => ( is => 'rw' ); |
---|
7 | has title => ( is => 'rw' ); |
---|
8 | has ctime => ( is => 'ro' ); |
---|
9 | has mtime => ( |
---|
10 | is => 'ro', |
---|
11 | # mtime defaults to ctime |
---|
12 | default => sub { $_[0]->ctime }, |
---|
13 | lazy => 1, |
---|
14 | ); |
---|
15 | has tags => ( is => 'rw' ); |
---|
16 | has bookmark_uri => ( is => 'rw' ); |
---|
17 | |
---|
18 | sub BUILD { |
---|
19 | my $self = shift; |
---|
20 | my $args = shift; |
---|
21 | if ($args->{base_uri}) { |
---|
22 | $self->bookmark_uri(URI->new_abs($self->id, $args->{base_uri})); |
---|
23 | } |
---|
24 | } |
---|
25 | |
---|
26 | sub TO_JSON { |
---|
27 | my $self = shift; |
---|
28 | return { |
---|
29 | id => $self->id, |
---|
30 | uri => $self->uri, |
---|
31 | title => $self->title, |
---|
32 | ctime => $self->ctime, |
---|
33 | mtime => $self->mtime, |
---|
34 | tags => $self->tags, |
---|
35 | ($self->bookmark_uri ? (bookmark_uri => $self->bookmark_uri->canonical->as_string) : ()), |
---|
36 | }; |
---|
37 | } |
---|
38 | |
---|
39 | # module return |
---|
40 | 1; |
---|
Note: See
TracBrowser
for help on using the repository browser.