summaryrefslogtreecommitdiff
path: root/lib/MooseX/Net/API/Meta/Method/APIDeclare.pm
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-06-03 14:11:54 +0200
committerfranck cuny <franck@lumberjaph.net>2010-06-03 14:11:54 +0200
commitc94d18646c9116502cfb212de1ab9f8df2377b90 (patch)
tree8616e6480f759fcc73a3722443671708434f63ee /lib/MooseX/Net/API/Meta/Method/APIDeclare.pm
parentremove -d, add uploadtocpan (diff)
downloadnet-http-api-c94d18646c9116502cfb212de1ab9f8df2377b90.tar.gz
rename some methods
Diffstat (limited to 'lib/MooseX/Net/API/Meta/Method/APIDeclare.pm')
-rw-r--r--lib/MooseX/Net/API/Meta/Method/APIDeclare.pm39
1 files changed, 15 insertions, 24 deletions
diff --git a/lib/MooseX/Net/API/Meta/Method/APIDeclare.pm b/lib/MooseX/Net/API/Meta/Method/APIDeclare.pm
index 14fb83d..503ed82 100644
--- a/lib/MooseX/Net/API/Meta/Method/APIDeclare.pm
+++ b/lib/MooseX/Net/API/Meta/Method/APIDeclare.pm
@@ -3,33 +3,26 @@ package MooseX::Net::API::Meta::Method::APIDeclare;
use Moose::Role;
use MooseX::Net::API::Error;
-has options => (
+my @accepted_options = qw/
+ api_base_url
+ api_format
+ api_username
+ api_password
+ authentication
+ authentication_method
+ /;
+
+has api_options => (
is => 'ro',
traits => ['Hash'],
isa => 'HashRef[Str|CodeRef]',
default => sub { {} },
lazy => 1,
handles => {
- set_option => 'set',
- get_option => 'get',
+ set_api_option => 'set',
+ get_api_option => 'get',
},
);
-has accepted_options => (
- is => 'ro',
- traits => ['Array'],
- isa => 'ArrayRef[Str]',
- default => sub {
- [ qw/api_base_url
- api_format
- api_username
- api_password
- authentication
- authentication_method/
- ];
- },
- lazy => 1,
- auto_deref => 1,
-);
sub add_net_api_declare {
my ($meta, $name, %options) = @_;
@@ -38,7 +31,7 @@ sub add_net_api_declare {
die MooseX::Net::API::Error->new(
reason => "'useragent' must be a CODE ref")
unless ref $options{useragent} eq 'CODE';
- $meta->set_option(useragent => delete $options{useragent});
+ $meta->set_api_option(useragent => delete $options{useragent});
}
# XXX for backward compatibility
@@ -49,11 +42,9 @@ sub add_net_api_declare {
}
}
- for my $attr ($meta->accepted_options) {
- $meta->set_option($attr => $options{$attr}) if defined $options{$attr};
+ for my $attr (@accepted_options) {
+ $meta->set_api_option($attr => $options{$attr}) if defined $options{$attr};
}
-
- # XXX before_request after_request
}
1;