I have a subclass extending parent class method via inner() and augment
package C1; use Moose; sub html { my $this = shift; return '<html>' . '<body>' . inner() . '</body>' . '</html>'; } package C2; use Moose; extends 'C1'; augment html => sub { return 'C2'; };
I want to add another augmentable method, which content is not mandatory, i.e. I don't want to supply augment in every subclass.warn C2->new->html; # yields # <html><body>C2</body></html>
package C1; use Moose; sub html { my $this = shift; return '<html>' . $this->head . '<body>' . inner() . '</body>' . '</html>'; } sub head { return '<head>' . (inner() || '') . '</head>'; } package C2; use Moose; extends 'C1'; augment html => sub { return 'C2'; };
But if I don't supply the content of head method in subclass then the content of html method is used:
warn C2->new->html; # yields # <html><head>C2</head><body>C2</body></html>
So is it possible to use more than one augmentable method, with some of them having "optional" content?
Thanks for any reply including those: "You should not do this, ..."
Roman
In reply to Moose - two augmented methods in one class by roman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |