summary refs log tree commit diff
path: root/lib/MooseX
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-06-02 18:56:01 +0200
committerfranck cuny <franck@lumberjaph.net>2010-06-02 18:56:01 +0200
commit6b5a00cab381d5ed55d662be44b67112e13fbb1c (patch)
tree320f288f44c04bcd899db175d60c47a31890d698 /lib/MooseX
parentclean (diff)
downloadmoosex-net-api-6b5a00cab381d5ed55d662be44b67112e13fbb1c.tar.gz
clean code
Diffstat (limited to 'lib/MooseX')
-rw-r--r--lib/MooseX/Net/API/Meta/Method/APIDeclare.pm24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/MooseX/Net/API/Meta/Method/APIDeclare.pm b/lib/MooseX/Net/API/Meta/Method/APIDeclare.pm
index 4ad5150..b65ef41 100644
--- a/lib/MooseX/Net/API/Meta/Method/APIDeclare.pm
+++ b/lib/MooseX/Net/API/Meta/Method/APIDeclare.pm
@@ -14,6 +14,22 @@ has options => (
         get_option => 'get',
     },
 );
+has accepted_options => (
+    is      => 'ro',
+    traits  => ['Array'],
+    isa     => 'ArrayRef[Str]',
+    default => sub {
+        [   qw/api_base_url
+              api_format
+              api_useranem
+              api_password
+              authentication
+              authentication_method/
+        ];
+    },
+    lazy       => 1,
+    auto_deref => 1,
+);
 
 sub add_net_api_declare {
     my ($meta, $name, %options) = @_;
@@ -25,8 +41,6 @@ sub add_net_api_declare {
         $meta->set_option(useragent => delete $options{useragent});
     }
 
-    # XXX custom authentication_method (replace with before request !)
-
     # XXX for backward compatibility
     for my $attr (qw/base_url format username password/) {
         my $attr_name = "api_" . $attr;
@@ -35,15 +49,11 @@ sub add_net_api_declare {
         }
     }
 
-    for my $attr (qw/api_base_url api_format api_username api_password authentication/) {
+    for my $attr ($meta->accepted_options) {
         $meta->set_option($attr => $options{$attr}) if defined $options{$attr};
     }
 
     # XXX before_request after_request
-
-    if (keys %options) {
-        # XXX croak
-    }
 }
 
 1;