Changeset 91 in bookmarks


Ignore:
Timestamp:
06/05/15 19:32:33 (10 years ago)
Author:
peter
Message:

change TO_JSON() method name to to_hashref() to emphasize its multiple uses

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bkmk

    r88 r91  
    3434        my $identifier = shift; 
    3535        my $bookmark = find_bookmark($identifier); 
    36         print $bookmark ? Dump($bookmark->TO_JSON) : "Not Found\n"; 
     36        print $bookmark ? Dump($bookmark->to_hashref) : "Not Found\n"; 
    3737    }, 
    3838     
     
    4141        my $title = defined $TITLE ? $TITLE : fetch_title($uri); 
    4242        my $bookmark = $bookmarks->add({ uri => $uri, title => $title, tags => \@tags }); 
    43         print Dump($bookmark->TO_JSON); 
     43        print Dump($bookmark->to_hashref); 
    4444    }, 
    4545 
     
    5151        # TODO: list by tags, date, etc. 
    5252        # TODO: coordinate this commandline script with the CGI app 
    53         print Dump([ map { $_->TO_JSON } @{ $resources->results } ]); 
     53        print Dump([ map { $_->to_hashref } @{ $resources->results } ]); 
    5454    }, 
    5555 
     
    6060            $bookmark->tags(\@tags); 
    6161            $bookmarks->update($bookmark); 
    62             print Dump($bookmark->TO_JSON); 
     62            print Dump($bookmark->to_hashref); 
    6363        } else { 
    6464            die "Not found\n"; 
     
    7777    dump => sub { 
    7878        my ($dump_file) = @_; 
    79         my $dump = [ map { $_->TO_JSON } @{ $bookmarks->search->results } ]; 
     79        my $dump = [ map { $_->to_hashref } @{ $bookmarks->search->results } ]; 
    8080        $dump_file ? YAML::DumpFile($dump_file, $dump) : print Dump($dump); 
    8181    }, 
  • trunk/lib/Bookmark.pm

    r75 r91  
    3232} 
    3333 
    34 sub TO_JSON { 
     34sub to_hashref { 
    3535    my $self = shift; 
    3636    return { 
  • trunk/lib/Bookmarks/Controller.pm

    r88 r91  
    143143         
    144144        if ($format eq 'json') { 
    145             my $json = decode_utf8(JSON->new->utf8->convert_blessed->encode($bookmark)); 
     145            my $json = decode_utf8(JSON->new->utf8->convert_blessed->encode($bookmark->to_hashref)); 
    146146            return [200, ['Content-Type' => 'application/json; charset=UTF-8', 'Last-Modified' => $last_modified], [$json]]; 
    147147        } else { 
  • trunk/lib/Bookmarks/List.pm

    r88 r91  
    9797    my $json = decode_utf8( 
    9898        JSON->new->utf8->convert_blessed->encode({ 
    99             bookmarks => $self->results, 
     99            bookmarks => [ map { $_->to_hashref } @{ $self->results } ], 
    100100        }) 
    101101    ); 
Note: See TracChangeset for help on using the changeset viewer.