U
U
unama0a2015-02-22 12:04:00
Perl
unama0a, 2015-02-22 12:04:00

Proper use of a controller in Mojo?

There is one application controller (mojo, MVC).
There is a code that sets the secret phrase for cookies. The developers suggest
$self->secrets ('SeCreTe');
But I don't like to use the $self pointer every time, because It's not always clear where he's referring to.
Is it correct to use

my $secrets = $self->secrets;
  $secrets = $self->secrets(' SeCreTe ');

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
pcdesign, 2015-02-24
@pcdesign

It makes sense to subscribe to
mail.pm.org/mailman/listinfo/moscow-pm
moscow.pm.org
and ask there.
The mailing list is very active, they respond quickly.

D
dionys, 2015-02-26
@dionys

Inside a controller module, $selfpoints to a controller; inside an application module, points to an application.
You need to set the secret once in the startupapplication method:

sub startup {
    my ($app) = @_;
    $app->secrets(['secret']);
    ...
}

U
unama0a, 2015-02-26
@unama0a

In general, having received answers, I left it like that.

sub startup {
my $self = shift;
$self->secrets('sec');
...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question