summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2015-03-30 00:12:37 -0400
committerJesse Luehrs <doy@tozt.net>2015-03-30 00:12:37 -0400
commit5098904f4f641567cb37b2a08d486236b38af775 (patch)
treee374f1afae4c741565fb0c184f02c02e664bd2cc
parent07b5a36831340aee820ecb134b6edd3b8b84ca40 (diff)
downloadwww-pocket-5098904f4f641567cb37b2a08d486236b38af775.tar.gz
www-pocket-5098904f4f641567cb37b2a08d486236b38af775.zip
restrict which methods are considered commands
-rw-r--r--lib/WWW/Pocket/Script.pm15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/WWW/Pocket/Script.pm b/lib/WWW/Pocket/Script.pm
index ddf7291..5238931 100644
--- a/lib/WWW/Pocket/Script.pm
+++ b/lib/WWW/Pocket/Script.pm
@@ -50,7 +50,7 @@ sub run {
my @argv = @_;
my $method = shift @argv;
- if ($self->can($method)) {
+ if ($self->_method_is_command($method)) {
return $self->$method(@argv);
}
else {
@@ -58,6 +58,19 @@ sub run {
}
}
+sub _method_is_command {
+ my $self = shift;
+ my ($name) = @_;
+
+ return if $name eq 'run' || $name eq 'meta';
+ return if $name =~ /^_/;
+ my $method = $self->meta->find_method_by_name($name);
+ return unless $method;
+ return if $method->isa('Class::MOP::Method::Accessor');
+
+ return 1;
+}
+
sub authenticate {
my $self = shift;
$self->pocket;