| Net-FluidDB documentation | Contained in the Net-FluidDB distribution. |
Net::FluidDB::User - FluidDB users
use Net::FluidDB::User; $user = Net::FluidDB::User->get($fdb, $username); $user->name;
Net::FluidDB::User models FluidDB users.
Net::FluidDB::User is a subclass of Net::FluidDB::Base.
Net::FluidDB::User consumes the role Net::FluidDB::HasObject.
Retrieves the user with username $username from FluidDB.
Net::FluidDB provides a convenience shortcut for this method.
Returns the username of the user.
Returns the name of the user.
Xavier Noria (FXN), <fxn@cpan.org>
Copyright (C) 2009-2011 Xavier Noria
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
| Net-FluidDB documentation | Contained in the Net-FluidDB distribution. |
package Net::FluidDB::User; use Moose; extends 'Net::FluidDB::Base'; with 'Net::FluidDB::HasObject'; has name => (is => 'ro', isa => 'Str'); has username => (is => 'ro', isa => 'Str'); sub get { my ($class, $fdb, $username) = @_; $fdb->get( path => $class->abs_path('users', $username), headers => $fdb->accept_header_for_json, on_success => sub { my $response = shift; my $h = $class->json->decode($response->content); my $user = $class->new(fdb => $fdb, username => $username, %$h); $user->_set_object_id($h->{id}); $user; } ); } no Moose; __PACKAGE__->meta->make_immutable; 1; __END__