Mailing List Archive

The lib of "my ($self, $c) = @_;"
Hi all!
In a subroutine of a controller, we always use this command: my ($self, $c)
= @_;
And then use some method of $self, $c, example: $c -> stash, $c -> forward.
How do I get all method of $c and $self (such as automatic complete of some
editor of another languages)

Pls give a link or document to understand them.

--
Regards!
Nguyen Hong Thai
The lib of "my ($self, $c) = @_;" [ In reply to ]
Hi all!
In a subroutine of a controller, we always use this command: my ($self, $c)
= @_;
And then use some method of $self, $c, example: $c -> stash, $c -> forward.
How do I get all method of $c and $self (such as automatic complete of some
editor of another languages)

Pls give a link or document to understand them.

--
Regards!
Nguyen Hong Thai
Re: The lib of "my ($self, $c) = @_;" [ In reply to ]
On 23 November 2010 03:45, NGUYENHONGTHAI <nguyenhongthaiptit@gmail.com>wrote:

> In a subroutine of a controller, we always use this command: my ($self, $c)
> = @_;
> And then use some method of $self, $c, example: $c -> stash, $c -> forward.
> How do I get all method of $c and $self (such as automatic complete of some
> editor of another languages)
>
> Pls give a link or document to understand them.
>
>
You can do it with the debugger:
http://search.cpan.org/~zarquon/Catalyst-Manual-5.8005/lib/Catalyst/Manual/Tutorial/07_Debugging.pod
<http://search.cpan.org/~zarquon/Catalyst-Manual-5.8005/lib/Catalyst/Manual/Tutorial/07_Debugging.pod>section
"Next, list the methods available on our Book model:"
use the debugger 'm' command on $c, model objects etc. to see what methods
and inheritance tree are in use

Alternatively, read the docs
http://search.cpan.org/perldoc?Catalyst
and manual
http://search.cpan.org/~zarquon/Catalyst-Manual-5.8005/lib/Catalyst/Manual.pm
or read through the source code to figure out the class hierarchy
http://cpansearch.perl.org/src/BOBTFISH/Catalyst-Runtime-5.80029/lib/


Cheers, Peter
http://perl.dragonstaff.co.uk
Re: The lib of "my ($self, $c) = @_;" [ In reply to ]
Since Catalyst uses Moose, you can inspect the $c and $self objects using the meta() method of these objects.

For example, you can print the methods provided by $c and $self, and their attributes using:

sub methods : Local {
my ($self, $c) = @_;

my $body;
$body .= $_->name . '<br>' for $c->meta->get_all_methods;
$body .= $_->name . '<br>' for $c->meta->get_all_attributes;

$c->res->body($body);
}

If you want to see the modules that provide these methods, you can also use

$body .= $_->fully_qualified_name . '<br>' for $c->meta->get_all_methods;

And the same thing for $self...

Octavian

----- Original Message -----
From: "NGUYENHONGTHAI" <nguyenhongthaiptit@gmail.com>
To: <catalyst-dev@lists.scsys.co.uk>
Sent: Tuesday, November 23, 2010 5:45 AM
Subject: [Catalyst-dev] The lib of "my ($self, $c) = @_;"


> Hi all!
> In a subroutine of a controller, we always use this command: my ($self, $c)
> = @_;
> And then use some method of $self, $c, example: $c -> stash, $c -> forward.
> How do I get all method of $c and $self (such as automatic complete of some
> editor of another languages)
>
> Pls give a link or document to understand them.
>
> --
> Regards!
> Nguyen Hong Thai
>


--------------------------------------------------------------------------------


> _______________________________________________
> Catalyst-dev mailing list
> Catalyst-dev@lists.scsys.co.uk
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst-dev
>

_______________________________________________
Catalyst-dev mailing list
Catalyst-dev@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst-dev