Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Dev

The lib of "my ($self, $c) = @_;"

 

 

Catalyst dev RSS feed   Index | Next | Previous | View Threaded


nguyenhongthaiptit at gmail

Nov 22, 2010, 7:45 PM

Post #1 of 4 (1176 views)
Permalink
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


nguyenhongthaiptit at gmail

Nov 22, 2010, 7:45 PM

Post #2 of 4 (1118 views)
Permalink
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


peter at dragonstaff

Nov 23, 2010, 4:32 AM

Post #3 of 4 (1119 views)
Permalink
Re: The lib of "my ($self, $c) = @_;" [In reply to]

On 23 November 2010 03:45, NGUYENHONGTHAI <nguyenhongthaiptit [at] gmail>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


orasnita at gmail

Nov 27, 2010, 3:44 AM

Post #4 of 4 (1123 views)
Permalink
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 [at] gmail>
To: <catalyst-dev [at] lists>
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 [at] lists
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst-dev
>

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

Catalyst dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.