Net::FluidDB::User - FluidDB users


Net-FluidDB documentation Contained in the Net-FluidDB distribution.

Index


Code Index:

NAME

Top

Net::FluidDB::User - FluidDB users

SYNOPSIS

Top

 use Net::FluidDB::User;

 $user = Net::FluidDB::User->get($fdb, $username);
 $user->name;

DESCRIPTION

Top

Net::FluidDB::User models FluidDB users.

USAGE

Top

Inheritance

Net::FluidDB::User is a subclass of Net::FluidDB::Base.

Roles

Net::FluidDB::User consumes the role Net::FluidDB::HasObject.

Class methods

Net::FluidDB::User->get($fdb, $username)

Retrieves the user with username $username from FluidDB.

Net::FluidDB provides a convenience shortcut for this method.

Instance Methods

$user->username

Returns the username of the user.

$user->name

Returns the name of the user.

FLUIDDB DOCUMENTATION

Top

FluidDB high-level description

http://doc.fluidinfo.com/fluidDB/users.html

FluidDB API specification

http://api.fluidinfo.com/fluidDB/api/*/users/*

AUTHOR

Top

Xavier Noria (FXN), <fxn@cpan.org>

COPYRIGHT AND LICENSE

Top


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__