Using Mason2. Have 3 components.
/Base.mc
/tmp/Base.mc
/tmp/index.mc
The /tmp/index.mc
with a content:
hello from <% $m->request_path %></br>
<% $.Some %>
the $.Some
is an method defined in the /Base.mc
:
<%augment wrap><% inner() %></%augment>
<%method Some>
The default "Some" method defined in the <% __PACKAGE__ %>
</%method>
the /tmp/Base.mc
contains only
<%augment wrap><% inner() %></%augment>
Requesting /tmp/index
prints:
hello from /tmp/index
The default "Some" method defined in the MC0::Base_mc
Now added the Some
method into /tmp/Base.mc
<%method Some>
Redefined "Some" method in <% __PACKAGE__ %>
</%method>
Requesting /tmp/index
again, it prints:
hello from /tmp/index
Redefined "Some" method in MC0::tmp_Base_mc
It honored the redefined Some
method in the wrapped /tmp/Base.mc
The question is:
If Mason allows redefine methods as above, what is the purpose of the <%override method>
? Does the <%override Some>
something differently? (when i tested, it prints the same).
EDIT Maybe the question can be reduced to the following perl code.
use 5.014;
use warnings;
package My;
use Moose;
sub some { say "some from " . __PACKAGE__ }
package My2;
use Moose;
extends 'My';
sub some { say "another some from " . __PACKAGE__ }
#the above line is an correct way to refefine a sub "some"?
#so don;t need to use the
#override 'some' => sub { say "another some from " . __PACKAGE__ };
package main;
use My2;
my $m = My2->new();
$m->some();
in both cases (e.g. "plain" redefine and redefine with "override") prints:
another some from My2
So, the only difference is the possibility of calling the super()
in the some
with override
? and sorry if I missed some basic knowlegde... ;(