Re: [Mojolicious] Inheriting "live" attribute values of parent class with Mojo::Base

2017-04-06 Thread Dotan Dimet
You initialize $c->token with a non-default value, but not $c->Tiger->token. You could change the 4th line to has 'Tiger' => sub { Cat::Tiger-> new(token => shift->token) }; http://mojolicious.org/perldoc/Mojo/Base#attr says: The ca

Re: [Mojolicious] Inheriting "live" attribute values of parent class with Mojo::Base

2017-04-06 Thread Dan Book
There is not really any automatic way to do this in Mojo::Base, it's a very simple module. But you could do something like this. has 'token' => sub { my $self = shift; exists $self->{Tiger} ? $self->Tiger->token : $self->token }; This would only affect the default of course, and would not update

[Mojolicious] Inheriting "live" attribute values of parent class with Mojo::Base

2017-04-06 Thread Pavel Serikov
Question in comment to code :) package Cat; use Mojo::Base -base; has 'token' => '12345'; has 'Tiger' => sub { Cat::Tiger-> new }; package Cat::Tiger; use Mojo::Base 'Cat'; package main; my $c = Cat->new(token=>'54321'); warn Dumper $c->Tiger->token; # how to make '54321' instead of '12345' ?

Re: [Mojolicious] Re: $c->req->query_params('x') value only?

2017-04-06 Thread Stefan Adams
On Thu, Apr 6, 2017 at 11:24 AM, iaw4 wrote: > the Mojo way to read unique and simple GET parameters: > Even easier, you might just want Mojolicious::Controller's param method . get '/' => sub { my $c = shift; my $x = $c->*param*(

[Mojolicious] Re: $c->req->query_params('x') value only?

2017-04-06 Thread iaw4
the Mojo way to read unique and simple GET parameters: use Mojo::Parameters; my $paramsobject= $c->req->query_params; my $xcontent= $paramsobject->param('x'); -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and

Re: [Mojolicious] $c->req->query_params('x') value only?

2017-04-06 Thread iaw4
use $x= $c->req->query_params('x')->[0] for the tag (here 'x'), and $xval=$c->req->query_params('x')->[1] for the value of the tag (if passed with x=value). -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and sto