[Catalyst-dev] The lib of "my ($self, $c) = @_;"

Octavian Rasnita orasnita at gmail.com
Sat Nov 27 11:44:15 GMT 2010


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.com>
To: <catalyst-dev at 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 at lists.scsys.co.uk
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst-dev
>



More information about the Catalyst-dev mailing list