[libflickr-api-perl] 27/40: added optional subclassing. documented new() method
Lucas Kanashiro
kanashiro-guest at moszumanska.debian.org
Sat Jul 25 21:12:19 UTC 2015
This is an automated email from the git hooks/post-receive script.
kanashiro-guest pushed a commit to tag 1.08
in repository libflickr-api-perl.
commit 366dcb30d8d45219fa1452cb9336016a108d07ba
Author: Cal Henderson <cal at iamcal.com>
Date: Sat May 11 14:51:45 2013 -0700
added optional subclassing.
documented new() method
---
Changes | 3 +++
README | 2 +-
lib/Flickr/API.pm | 53 ++++++++++++++++++++++++++++++++++++++++++++++-------
3 files changed, 50 insertions(+), 8 deletions(-)
diff --git a/Changes b/Changes
index ce0b1cd..efad38d 100644
--- a/Changes
+++ b/Changes
@@ -21,3 +21,6 @@ Changes to Flickr::API
1.05, 2012-09-12
* Updated Flickr API urls from http://www.flickr.com/services/ to http://api.flickr.com/services/.
+
+1.06, 2013-05-11
+ * Added `lwpobj` argument, to allow using subclasses of LWP::UserAgent
diff --git a/README b/README
index eb6c877..1d00612 100644
--- a/README
+++ b/README
@@ -29,5 +29,5 @@ This module requires these other modules and libraries:
COPYRIGHT AND LICENCE
-Copyright (C) 2004-2012 Cal Henderson <cal at iamcal.com>
+Copyright (C) 2004-2013 Cal Henderson <cal at iamcal.com>
License: Perl Artistic License 2.0
diff --git a/lib/Flickr/API.pm b/lib/Flickr/API.pm
index de49288..8175307 100644
--- a/lib/Flickr/API.pm
+++ b/lib/Flickr/API.pm
@@ -7,15 +7,29 @@ use XML::Parser::Lite::Tree;
use Flickr::API::Request;
use Flickr::API::Response;
use Digest::MD5 qw(md5_hex);
+use Scalar::Util qw(blessed);
our @ISA = qw(LWP::UserAgent);
-our $VERSION = '1.05';
+our $VERSION = '1.06';
sub new {
my $class = shift;
my $options = shift;
- my $self = new LWP::UserAgent;
+
+ my $self;
+ if ($options->{lwpobj}){
+ my $lwpobj = $options->{lwpobj};
+ if (defined($lwpobj)){
+ my $lwpobjtype = Scalar::Util::blessed($lwpobj);
+ if (defined($lwpobjtype)){
+ $self = $lwpobj;
+ @ISA = ($lwpobjtype);
+ }
+ }
+ }
+ $self = new LWP::UserAgent unless $self;
+
$self->{api_key} = $options->{key};
$self->{api_secret} = $options->{secret};
$self->{rest_uri} = $options->{rest_uri} || 'http://api.flickr.com/services/rest/';
@@ -184,9 +198,34 @@ A simple interface for using the Flickr API.
C<Flickr::API> is a subclass of L<LWP::UserAgent>, so all of the various
proxy, request limits, caching, etc are available.
-=head2 METHODS
+=head1 METHODS
+
+=over
+
+=item C<new({ opt =E<gt> 'value', ... })>
+
+Returns as new C<Flickr::API> object. The options are as follows:
+
+=over
+
+=item C<key> (required)
+
+Your API key
-=over 4
+=item C<secret>
+
+Your API key's secret
+
+=item C<rest_uri> & C<auth_uri>
+
+Override the URIs used for contacting the API.
+
+=item C<lwpobj>
+
+Base the C<Flickr::API> on this object, instead of creating a new instance of C<LWP::UserAgent>.
+This is useful for using the features of e.g. C<LWP::UserAgent::Cached>.
+
+=back
=item C<execute_method($method, $args)>
@@ -206,16 +245,16 @@ For web-based applications I<$frob> is an optional parameter.
Returns undef if a secret was not specified when creating the C<Flickr::API> object.
-
=back
-
=head1 AUTHOR
-Copyright (C) 2004-2012, Cal Henderson, E<lt>cal at iamcal.comE<gt>
+Copyright (C) 2004-2013, Cal Henderson, E<lt>cal at iamcal.comE<gt>
Auth API patches provided by Aaron Straup Cope
+Subclassing patch from AHP
+
=head1 SEE ALSO
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libflickr-api-perl.git
More information about the Pkg-perl-cvs-commits
mailing list