Elive

 view release on metacpan or  search on metacpan

lib/Elive/Entity/Session.pm  view on Meta::CPAN

}

=head2 list

List all sessions that match a given criteria:

    my $sessions = Elive::Entity::Session->list( filter => "(name like '*Sample*')" );

=cut

sub list {
    my $class = shift;
    my %opt = @_;

    my $connection = $opt{connection} || $class->connection
	or die "not connected";

    my $meetings = Elive::Entity::Meeting->list(%opt);

    my @sessions = map {
	my $meeting = $_;

	my $self = $class->construct({id => $meeting->meetingId},
				     connection => $connection);

	$self->meeting($meeting);

	$self;
    } @$meetings;

    return \@sessions;
}

=head2 delete

Deletes a completed or unwanted session from the Elluminate server.

    my $session = Elive::Entity::Session->retrieve( $session_id );
    $session->delete;

Note that a session, will have its C<deleted> property immediately set to true,
but may remain accessible for a short period of time until garbage collected.

So to check for a deleted session:

    my $session = Elive::Entity::Session->retrieve( $session_id ); 
    my $session_is_deleted = !$session || $session->deleted;

=cut

sub delete {
    my $self = shift;
    my %opt = @_;

    $self->meeting->delete;
    $self->_deleted(1);

    my $delegates = $self->_delegates;

    foreach my $delegate (sort keys %$delegates) {
        # ELM cascades the delete for us
	$self->$delegate->_deleted(1) if $self->{$delegate};
    }

    return 1;
}

=head2 is_changed

Returns a list of properties that have unsaved changes.

     my $session = Elive::Entity::Session->retrieve( $session_id);
     #
     # ..then later on
     #
     $session->seats( $session->seats + 5);
     @changed = $session->is_changed;
     #
     # @changed will contained 'seats', plus any other unsaved updates.
     #

Destroying an object with unsaved changes will cause a warning. To avoid this,
you will either need to call C<update> on the object to save the changes, or
C<revert> to discard the changes.

=cut

sub is_changed {
    my $self = shift;

    my $delegates = $self->_delegates;

    return map {$self->{$_}? $self->$_->is_changed: ()} (sort keys %$delegates)
}

=head2 revert

    $session->revert('seats'); # revert just the 'seats' property
    $session->revert();        # revert everything

Reverts unsaved updates.

=cut

sub revert {
    my $self = shift;

    my $delegates = $self->_delegates;

    for (sort keys %$delegates) {
	$self->$_->revert if $self->{$_};
    }

    return $self;
}

=head1 Working with Participants

=head2 Constructing Participant Lists

A simple input list of participants might look like:



( run in 0.497 second using v1.01-cache-2.11-cpan-524268b4103 )