Support 'use Web::Simple;' to default to current package
[catagits/Web-Simple.git] / lib / Web / Simple.pm
index e717bcd..9d5efbb 100644 (file)
@@ -4,7 +4,7 @@ use strict;
 use warnings FATAL => 'all';
 use 5.008;
 
-our $VERSION = '0.003';
+our $VERSION = '0.004';
 
 sub setup_all_strictures {
   strict->import;
@@ -23,7 +23,7 @@ sub setup_dispatch_strictures {
 sub import {
   setup_dispatch_strictures();
   my ($class, $app_package) = @_;
-  $class->_export_into($app_package);
+  $class->_export_into($app_package||caller);
 }
 
 sub _export_into {
@@ -184,23 +184,23 @@ is encountered in other code.
    # matches: GET /user/1.htm?show_details=1
    #          GET /user/1.htm
    sub (GET + /user/* + ?show_details~ + .htm|.html|.xhtml) {
-     shift; my ($user_id, $show_details) = @_;
+     my ($self, $user_id, $show_details) = @_;
      ...
    },
    # matches: POST /user?username=frew
    #          POST /user?username=mst&first_name=matt&last_name=trout
    sub (POST + /user + ?username=&*) {
-      shift; my ($username, $misc_params) = @_;
+      my ($self, $username, $misc_params) = @_;
      ...
    },
    # matches: DELETE /user/1/friend/2
    sub (DELETE + /user/*/friend/*) {
-     shift; my ($user_id, $friend_id) = @_;
+     my ($self, $user_id, $friend_id) = @_;
      ...
    },
    # matches: PUT /user/1?first_name=Matt&last_name=Trout
    sub (PUT + /user/* + ?first_name~&last_name~) {
-     shift; my ($user_id, $first_name, $last_name) = @_;
+     my ($self, $user_id, $first_name, $last_name) = @_;
      ...
    },
    sub (/user/*/...) {
@@ -214,7 +214,7 @@ is encountered in other code.
             },
             # matches: DELETE /user/1/role/1
             sub (DELETE + /role/*) {
-              my $role_id = shift;
+              my $role_id = $_[1];
               ...
             },
          ];