Convos::Core - Convos backend
DESCRIPTION
Convos::Core is the heart of the Convos backend.
SYNOPSIS
use Convos::Core;
use Convos::Core::Backend::File;
my $core = Convos::Core->new(backend => Convos::Core::Backend::File->new);
OBJECT GRAPH
-
Has one Convos::Core::Backend objects.
This object takes care of persisting data to disk.
Has many Convos::Core::User objects.
Represents a user of Convos.
Has many Convos::Core::Connection objects.
Represents a connection to a remote chat server, such as an IRC server.
Has many Convos::Core::Conversation objects.
This represents a conversation with zero or more users.
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 = $core->backend;
Holds a Convos::Core::Backend object.
home
$obj = $core->home;
$core = $core->home(Mojo::File->new($ENV{CONVOS_HOME});
Holds a Mojo::File object pointing to where Convos store data.
log
$log = $core->log;
$core = $core->log(Mojo::Log->new);
Holds a Mojo::Log object.
ready
$bool = $core->ready;
Will be true if the backend has loaded initial data.
METHODS
Convos::Core inherits all methods from Mojo::Base and implements the following new ones.
connection_profile
$profile = $core->connection_profile({id => $connection_id, ...});
Returns a shared Convos::Core::ConnectionProfile object for a connection ID.
get_connection_profile
$user = $core->get_connection_profile(\%attrs);
$user = $core->get_connection_profile($email);
Returns a Convos::Core::User object or undef.
connection_profiles
$collection = $core->connection_profiles;
Returns a Mojo::Collection of all known Convos::Core::ConnectionProfile objects.
connections_by_id
$collection = $core->connections_by_id($cid);
Finds all Convos::Core::Connection objects where id()
matches $cid
.
get_user
$user = $core->get_user(\%attrs);
$user = $core->get_user($email);
Returns a Convos::Core::User object or undef.
get_user_by_uid
$user = $core->get_user_by_uid($uid);
Returns a Convos::Core::User object or undef
.
new
$core = Convos::Core->new(%attrs);
$core = Convos::Core->new(\%attrs);
Object constructor. Builds "backend" if a classname is provided.
remove_connection_profile_p
$p = $core->remove_connection_profile_p($profile)->then(sub { $profile });
Used to delete a connection profile.
remove_user_p
$p = $core->remove_user_p($user)->then(sub { $user });
Used to delete user data and remove the user from $core
.
start
$core = $core->start;
Will start the backend. This means finding all users and start connections if state is not "disconnected".
user
$user = $core->user(\%attrs);
Returns a new Convos::Core::User object or updates an existing object.
users
$users = $core->users;
Returns an array-ref of of Convos::Core::User objects.
web_url
$url = $core->web_url($url);
Takes a path, or complete URL, merges it with "base_url" in Convos::Core::Settings and returns a new Mojo::URL object. Note that you need to call "to_abs" on that object for an absolute URL.