From 6b5a00cab381d5ed55d662be44b67112e13fbb1c Mon Sep 17 00:00:00 2001 From: franck cuny Date: Wed, 2 Jun 2010 18:56:01 +0200 Subject: clean code --- lib/MooseX/Net/API/Meta/Method/APIDeclare.pm | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'lib/MooseX/Net/API/Meta') 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; -- cgit 1.4.1