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 callback will be executed at accessor read time if there's no set value, and gets passed the current instance of the object as first argument.

On 06/04/2017 23:07, Pavel Serikov wrote:
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' ?

--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to