NAME

Convos::Core - Convos Models

DESCRIPTION

Convos::Core is a class which is used to instantiate other core objects with proper defaults.

SYNOPSIS

use Convos::Core;
use Convos::Core::Backend::File;
my $core = Convos::Core->new(backend => Convos::Core::Backend::File->new);

OBJECT GRAPH

All the child objects have pointers back to the parent object.

ATTRIBUTES

Convos::Core inherits all attributes from Mojo::Base and implements the following new ones.

backend

$obj = $self->backend;

Holds a Convos::Core::Backend object.

base_url

$url = $self->base_url;

Holds a Mojo::URL object that holds the public location of this Convos instance.

home

$obj = $self->home;
$self = $self->home(Mojo::File->new($ENV{CONVOS_HOME});

Holds a Mojo::File object pointing to where Convos store data.

METHODS

Convos::Core inherits all methods from Mojo::Base and implements the following new ones.

connect

$self->connect($connection, $cb);

This method will call "connect" in Convos::Core::Connection either at once or add the connection to a queue which will connect after an interval.

The reason for queuing connections is to prevent flooding the server.

Note: Connections to "localhost" will not be delayed, unless the first connect fails.

$cb is optional, but will be passed on to "connect" in Convos::Core::Connection if defined.

get_user

$user = $self->get_user(\%attrs);
$user = $self->get_user($email);

Returns a Convos::Core::User object or undef.

get_user_by_public_id

$user = $self->get_user_by_public_id($id);

Returns a Convos::Core::User object or undef.

new

$self = Convos::Core->new(%attrs);
$self = Convos::Core->new(\%attrs);

Object constructor. Builds "backend" if a classname is provided.

start

$self = $self->start;

Will start the backend. This means finding all users and start connections if state is not "disconnected".

user

$user = $self->user(\%attrs);

Returns a new Convos::Core::User object or updates an existing object.

users

$users = $self->users;

Returns an array-ref of of Convos::Core::User objects.

web_url

$url = $self->web_url($url);

Takes a path, or complete URL, merges it with "base_url" and returns a new Mojo::URL object. Note that you need to call "to_abs" on that object for an absolute URL.

AUTHOR

Jan Henning Thorsen - jhthorsen@cpan.org