AnyEvent-WebService-Tracks

 view release on metacpan or  search on metacpan

lib/AnyEvent/WebService/Tracks/Project.pm  view on Meta::CPAN

        } else {
            $cb_or_ctx->(undef);
        }
    } elsif(ref($cb_or_ctx) eq 'AnyEvent::WebService::Tracks::Context') {
        $self->{'default_context_id'} = $cb_or_ctx->id;
        $self->{'_dirty'}{'default_context_id'} = 1;
    } elsif(! defined($cb_or_ctx)) {
        $self->{'default_context_id'} = undef;
        $self->{'_dirty'}{'default_context_id'} = 1;
    } else {
        croak "AnyEvent::WebService::Tracks::Project::default_context accepts either a CODE reference or an AnyEvent::WebService::Tracks::Context";
    }
}

sub complete {
    my ( $self ) = @_;

    $self->{'state'}           = 'completed';
    $self->{'_dirty'}{'state'} = 1;
}

sub activate {
    my ( $self ) = @_;

    $self->{'state'}           = 'active';
    $self->{'_dirty'}{'state'} = 1;
}

sub hide {
    my ( $self ) = @_;

    $self->{'state'}           = 'hidden';
    $self->{'_dirty'}{'state'} = 1;
}

sub todos {
    my ( $self, $cb ) = @_;

    my $id = $self->id;
    $self->{'parent'}->fetch_multiple("projects/$id/todos",
        'AnyEvent::WebService::Tracks::Todo', $cb);
}

1;

__END__

=head1 NAME

AnyEvent::WebService::Tracks::Project - Tracks project objects

=head1 VERSION

0.02

=head1 SYNOPSIS

  $tracks->create_project($name, sub {
    my ( $project ) = @_;

    say $project->name;
  });

=head1 DESCRIPTION

AnyEvent::WebService::Tracks::Project objects represent GTD projects
in a Tracks installation.

=head1 READ-ONLY ATTRIBUTES

=head2 completed_at

When the project was completed.

=head2 created_at

When the project was created.

=head2 id

The Tracks ID of this project.

=head2 updated_at

When the project was last updated.

=head2 is_complete

Whether or not the project is complete.

=head2 is_active

Whether or not the project is complete.

=head2 is_hidden

Whether or not the project is hidden.

=head1 WRITABLE ATTRIBUTES

=head2 description

A description of this project.

=head2 name

This project's name (must be unique).

=head2 position

This project's position in the list of projects.

=head2 default_context($ctx_or_cb)

This functions a little bit differently than the other
accessors; it takes either a Context object, a callback,
or undef.  If a Context object or undef is provided, that
will be the new default context on the next update.  If
a callback is provided, a call is made to Tracks to retrieve
the context object, which is then provided to the callback.



( run in 0.644 second using v1.01-cache-2.11-cpan-483215c6ad5 )