From 6754c25c01c202ff788ffba6265d98b4b75f4db4 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Sun, 6 Jun 2010 16:52:32 +0200 Subject: initial commit --- lib/Net/HTTP/Console/Dispatcher/ExecuteMethod.pm | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/Net/HTTP/Console/Dispatcher/ExecuteMethod.pm (limited to 'lib/Net/HTTP/Console/Dispatcher/ExecuteMethod.pm') diff --git a/lib/Net/HTTP/Console/Dispatcher/ExecuteMethod.pm b/lib/Net/HTTP/Console/Dispatcher/ExecuteMethod.pm new file mode 100644 index 0000000..08536f3 --- /dev/null +++ b/lib/Net/HTTP/Console/Dispatcher/ExecuteMethod.pm @@ -0,0 +1,31 @@ +package Net::HTTP::Console::Dispatcher::ExecuteMethod; + +use Moose; +with qw/ + Net::HTTP::Console::Dispatcher + Net::HTTP::Console::Role::HTTP + /; + +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); +} + +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; + } +} + +1; -- cgit v1.2.3