From 1686d990b6e2c03e45a8f4ecdc87b78b8d2c0656 Mon Sep 17 00:00:00 2001 From: Steve Sanbeg Date: Wed, 12 Dec 2012 18:18:10 -0500 Subject: [PATCH] Add MongoDB::Collection::get_collection method, to replace deprecated AUTOLOAD functionality --- lib/MongoDB/Collection.pm | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/MongoDB/Collection.pm b/lib/MongoDB/Collection.pm index f2fedfb8..1e53dbe1 100644 --- a/lib/MongoDB/Collection.pm +++ b/lib/MongoDB/Collection.pm @@ -98,7 +98,23 @@ sub AUTOLOAD { my $coll = $AUTOLOAD; $coll =~ s/.*:://; - carp sprintf q{AUTOLOADed collection method names are deprecated and will be removed in a future release. Use $db->get_collection( '%s' ) instead.}, $coll; + carp sprintf q{AUTOLOADed collection method names are deprecated and will be removed in a future release. Use $collection->get_collection( '%s' ) instead.}, $coll; + + return $self->get_collection($coll); +} + +=head2 get_collection ($name) + + my $collection = $database->get_collection('foo'); + +Returns a L for the collection called C<$name> within this +collection. + +=cut + +sub get_collection { + my $self = shift @_; + my $coll = shift @_; return $self->_database->get_collection($self->name.'.'.$coll); }