mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-12 14:18:32 +00:00
Mo: Added an override() export
This commit is contained in:
11
lib/Mo.pm
11
lib/Mo.pm
@@ -177,6 +177,7 @@ sub Mo::import {
|
|||||||
_set_package_isa($caller, @_);
|
_set_package_isa($caller, @_);
|
||||||
_set_inherited_metadata($caller);
|
_set_inherited_metadata($caller);
|
||||||
},
|
},
|
||||||
|
override => \&override,
|
||||||
has => sub {
|
has => sub {
|
||||||
my $names = shift;
|
my $names = shift;
|
||||||
for my $attribute ( ref $names ? @$names : $names ) {
|
for my $attribute ( ref $names ? @$names : $names ) {
|
||||||
@@ -512,6 +513,16 @@ BEGIN {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub override {
|
||||||
|
my ($methods, $code) = @_;
|
||||||
|
my $caller = scalar caller;
|
||||||
|
|
||||||
|
for my $method ( ref($methods) ? @$methods : $methods ) {
|
||||||
|
my $full_method = "${caller}::${method}";
|
||||||
|
*{_glob_for $full_method} = $code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
1;
|
1;
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
Reference in New Issue
Block a user