summaryrefslogtreecommitdiff
path: root/lib/Net/HTTP/Console/Dispatcher/ExecuteMethod.pm
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-06-08 13:18:38 +0200
committerfranck cuny <franck@lumberjaph.net>2010-06-08 13:18:38 +0200
commit548f1a38f43a1b5da435b3a7c778f5ec3471f2f2 (patch)
tree4b36535807ec253033bc6f4ba0f259e62c74d1f6 /lib/Net/HTTP/Console/Dispatcher/ExecuteMethod.pm
parentupdate name of api methods; fetch doc from method (diff)
downloadnet-http-console-548f1a38f43a1b5da435b3a7c778f5ec3471f2f2.tar.gz
update regex; modify http methods; ..
Diffstat (limited to 'lib/Net/HTTP/Console/Dispatcher/ExecuteMethod.pm')
-rw-r--r--lib/Net/HTTP/Console/Dispatcher/ExecuteMethod.pm30
1 files changed, 12 insertions, 18 deletions
diff --git a/lib/Net/HTTP/Console/Dispatcher/ExecuteMethod.pm b/lib/Net/HTTP/Console/Dispatcher/ExecuteMethod.pm
index 08536f3..12a66e4 100644
--- a/lib/Net/HTTP/Console/Dispatcher/ExecuteMethod.pm
+++ b/lib/Net/HTTP/Console/Dispatcher/ExecuteMethod.pm
@@ -1,31 +1,25 @@
package Net::HTTP::Console::Dispatcher::ExecuteMethod;
use Moose;
-with qw/
- Net::HTTP::Console::Dispatcher
- Net::HTTP::Console::Role::HTTP
- /;
+with qw/Net::HTTP::Console::Dispatcher/;
sub dispatch {
my ($self, $input) = @_;
- $input =~ /^(\w+)\s(.*)$/;
- my $method = $1;
- my $args = $2;
- my $o = $self->lib->new();
- my ($content, $response) = $o->$method(%{JSON::decode_json($args)});
- $self->_set_and_show($content, $response);
+ (my $method, my $args) = $input =~ /^(\w+)\s(.*)$/;
+ my ($content, $response) =
+ $self->application->api_object->$method(%{JSON::decode_json($args)});
+ $self->application->_set_and_show($content, $response);
+ 1;
}
sub pattern {
my ($self, $input) = @_;
- $input =~ /^(\w+)/;
- my $method = $1;
- # find_api_method_by_name ?
- if ($self->application->lib->meta->find_method_by_name($method)) {
- return 1;
- }else{
- return 0;
- }
+ (my $method) = $input =~ /^(\w+)/;
+
+ # XXX find_api_method_by_name ?
+ $self->application->api_object->meta->find_method_by_name($method)
+ ? return $input
+ : return 0;
}
1;