NAME

Net::Fluidinfo::Object - Fluidinfo objects

SYNOPSIS

use Net::Fluidinfo::Object;

# create, with optional about
$object = Net::Fluidinfo::Object->new(
    fin   => $fin,
    about => $unique_about
);
$object->create;
$object->id; # returns the object's ID in Fluidinfo

# get by ID, optionally fetching about
$object = Net::Fluidinfo::Object->get_by_id($fin, $id, about => 1);

# get by about
$object = Net::Fluidinfo::Object->get_by_about($fin, $about);

# tag
$object->tag("fxn/likes");
$object->tag("fxn/rating", integer => 10);
$object->tag("fxn/avatar", 'image/png' => $image);

# retrieve a tag value
$value = $object->value("fxn/rating");

# retrieve a tag value and its type
($type, $value) = $object->value("fxn/rating");

# remove a tag
$object->untag("fxn/rating");

# search
@ids = Net::Fluidinfo::Object->search($fin, "has fxn/rating");

DESCRIPTION

Net::Fluidinfo::Object models Fluidinfo objects.

USAGE

Inheritance

Net::Fluidinfo::Object is a subclass of Net::Fluidinfo::Base.

Class methods

Net::Fluidinfo::Object->new(%attrs)

Constructs a new object. The constructor accepts these parameters:

fin (required)

An instance of Net::Fluidinfo.

about (optional)

A string, if any.

This constructor is only useful for creating new objects in Fluidinfo. Already existing objects are fetched with get_by_id or get_by_about:

Net::Fluidinfo::Object->get_by_id($fin, $id, %opts)

Retrieves the object with ID $id from Fluidinfo. Options are:

about (optional, default false)

Tells get whether you want to get the about attribute of the object.

If about is not fetched has_about will be false even if the object has an about attribute in Fluidinfo.

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

Net::Fluidinfo::Object->get_by_about($fin, $about)

Retrieves the object with about $about from Fluidinfo.

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

Net::Fluidinfo::Object->search($fin, $query)

Performs the query $query and returns a (possibly empty) array of strings with the IDs of the macthing objects.

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

Net::Fluidinfo::Object->has_tag($fin, $object_id, $tag_or_tag_path)

When you retrieve an object from Fluidinfo the instance has the paths of its tags as an attribute. But if you only have an object ID and are interested in checking whether the corresponding object has been tagged with a certain tag, this predicate is cheaper than fetching the object.

You can pass either a Net::Fluidinfo::Tag instance or a tag path in the rightmost argument.

Instance Methods

$object->create

Creates the object in Fluidinfo.

$object->id

Returns the UUID of the object, or undef if it is new.

$object->has_id

Predicate to test whether the object has an ID.

$object->about
$object->about($about)

Gets/sets the about attribute. About can't be modified in existing objects, the setter is only useful for new objects.

Note that you need to set the about flag when you fetch an object for this attribute to be initialized.

$object->has_about

Says whether the object has an about attribute.

Note that you need to set the about flag when you fetch an object for this attribute to be initialized.

$object->tag_paths

Returns the paths of the existing tags on the object as a (possibly empty) arrayref of strings.

$object->tag($tag_or_tag_path)
$object->tag($tag_or_tag_path, $value)
$object->tag($tag_or_tag_path, $type => $value)

Tags an object.

You can pass either a Net::Fluidinfo::Tag instance or a tag path in the first argument.

Native values

You need to specify the Fluidinfo type of native values using one of "null", "boolean", "integer", "float", "string", or "list_of_strings":

$object->tag("fxn/rating", integer => 7);

If $value is undef or an arrayref this is not required:

$object->tag("fxn/tags");                    # type null (inferred)
$object->tag("fxn/tags", undef);             # type null (inferred)
$object->tag("fxn/tags", ["perl", "moose"]); # type list_of_strings (inferred)

The elements of arrayrefs are stringfied if needed to ensure we send a list of strings.

Non-native values

To tag with a non-native value use a suitable MIME type for it:

$object->tag("fxn/foaf", "application/rdf+xml" => $foaf);
$object->value($tag_or_tag_path)

Gets the value of a tag on an object.

You can refer to the tag either with a Net::Fluidinfo::Tag instance or a tag path.

This method returns the very value in scalar context:

$value = $object->value("fxn/rating");

and also the type in list context:

($type, $value) = $object->value("fxn/rating");

For native values the type is one of "null", "boolean", "integer", "float", "string", or "list_of_strings". For non-native values the type is their MIME type.

$object->untag($tag_or_tag_path)

Untags an object.

FLUIDINFO DOCUMENTATION

Fluidinfo high-level description

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

Fluidinfo API documentation

http://doc.fluidinfo.com/fluidDB/api/objects.html

Fluidinfo API specification

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

AUTHOR

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

COPYRIGHT AND LICENSE

Copyright (C) 2009-2012 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.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 438:

'=item' outside of any '=over'