Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: MongoDB Perl Wrapper

by Corion (Patriarch)
on Sep 07, 2017 at 08:37 UTC ( [id://1198832]=note: print w/replies, xml ) Need Help??


in reply to MongoDB Perl Wrapper

Code-wise, I would make ->_set_connection respect the ->{port} and ->{host} arguments.

Also, I found a cascade of arguments makes testing and overriding things much easier in such routines. I would take the URL from the passed arguments, or from $self, in that order:

sub _set_connection { my( $self, %options ) = @_; my $url = $options{ url }; $url ||= sprintf 'http://%s:%s', $self->{host}, $self->{port}; return MongoDB->connect($url); }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1198832]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-25 15:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found