BusyBird

 view release on metacpan or  search on metacpan

lib/BusyBird/Main.pm  view on Meta::CPAN

    return $watcher;
}


1;

__END__

=pod

=head1 NAME

BusyBird::Main - main application object of BusyBird

=head1 SYNOPSIS

    use BusyBird::Main;
    
    my $main = BusyBird::Main->new;
    
    my $foo = $main->timeline("foo");
    my $bar = $main->timeline("bar");
    
    my @all_timelines = $main->get_all_timelines;
    $all_timelines[0]->name; ## => "foo"
    $all_timelines[1]->name; ## => "bar"
    
    $main->set_config(time_zone => "UTC");
    $foo->set_config(time_zone => "+0900");
    
    $main->get_timeline_config("foo", "time_zone"); ## => "+0900"
    $main->get_timeline_config("bar", "time_zone"); ## => "UTC"


=head1 DESCRIPTION

L<BusyBird::Main> is the main application object of L<BusyBird>.
It keeps application configuration and timelines (L<BusyBird::Timeline> objects).

L<BusyBird::Main> does not depend on L<PSGI> or any other controller mechanism.
If you want to create L<PSGI> application from L<BusyBird::Main>, check out L<BusyBird::Main::PSGI> class.

This module uses L<BusyBird::Log> for logging.

=head1 CLASS METHODS

=head2 $main = BusyBird::Main->new()

Creates a L<BusyBird::Main> object.

Users usually don't have to call this method.
The singleton instance of L<BusyBird::Main> object is maintained by L<BusyBird> module.
See L<BusyBird> and L<BusyBird::Manual::Tutorial> for detail.

=head1 OBJECT METHODS

=head2 $timeline = $main->timeline($name)

Returns the C<$timeline> whose name is C<$name> from the C<$main>.
C<$timeline> is a L<BusyBird::Timeline> object.
If C<$name> includes Unicode characters, it must be a character string (decoded string), not a binary string (encoded string).

If there is no timeline named C<$name> in C<$main>, a new timeline is created, installed and returned.

In L<BusyBird::Main>, timeline names must not contain a slash "/", because it confuses Web API.
If C<$name> contains a slash, the timeline IS created and returned, but it's NOT installed in the C<$main> object.
In that case, it logs a warning message.

If a new timeline is created by this method, it uses the StatusStorage object
given by C<< $main->get_config("default_status_storage") >> for that timeline.
See L<BusyBird::Manual::Config> for defail.

=head2 $timeline = $main->create_timeline($name)

Creates and returns a C<$timeline> like C<timeline()> method does, but not install it.

This method always creates a new L<BusyBird::Timeline> object.

=head2 $timeline = $main->get_timeline($name)

Returns the C<$timeline> whose name is C<$name> from the C<$main>.

If there is no timeline named C<$name> in C<$main>, it returns C<undef>.


=head2 @timelines = $main->get_all_timelines()

Returns the list of all timelines installed in the C<$main>.

=head2 $main->install_timeline($timeline)

Installs the given C<$timeline> to the C<$main>.

If a timeline with the same name as the given C<$timeline> is already installed in the C<$main>,
the old timeline is replaced by the given C<$timeline>.

You cannot install C<$timeline> whose name contains a slash "/".
In this case, the C<$timeline> is ignored and it logs a warning message.

=head2 $timeline = $main->uninstall_timeline($name)

Uninstalls the timeline whose name is C<$name> from the C<$main>.
It returns the uninstalled C<$timeline>.

If there is no timeline named C<$name>, it returns C<undef>.


=head2 $main->set_config($key1 => $value1, $key2 => $value2, ...)

Sets config parameters to the C<$main>.

C<$key1>, C<$key2>, ... are the keys for the config parameters, and
C<$value1>, C<$value2>, ... are the values for them.

See L<BusyBird::Manual::Config> for the list of config parameters.

=head2 $value = $main->get_config($key)

Returns the value of config parameter whose key is C<$key>.

If there is no config parameter associated with C<$key>, it returns C<undef>.



( run in 2.383 seconds using v1.01-cache-2.11-cpan-2398b32b56e )