Permalink
Browse files

Move connection opts

  • Loading branch information...
1 parent 133ee5c commit 4da29928893e4c6cb7d0d89eadf5eb84d5dfb76d @bmarini bmarini committed with ches Feb 6, 2011
Showing with 12 additions and 5 deletions.
  1. +5 −5 lib/rack/gridfs/endpoint/base.rb
  2. +7 −0 lib/rack/gridfs/endpoint/connection.rb
@@ -4,11 +4,7 @@ class Endpoint
module Base
def initialize(options = {})
- @options = {
- :hostname => 'localhost',
- :port => Mongo::Connection::DEFAULT_PORT,
- :lookup => :id
- }.merge(options)
+ @options = default_options.merge(options)
@lookup = @options[:lookup]
@mapper = @options[:mapper]
@@ -34,6 +30,10 @@ def db
protected
+ def default_options
+ { :lookup => :id }
+ end
+
def with_rescues
yield
rescue Mongo::GridError, BSON::InvalidObjectId => e
@@ -12,6 +12,13 @@ def initialize(*)
@options.values_at(:hostname, :port, :database, :username, :password)
end
+ def default_options
+ super.merge({
+ :hostname => 'localhost',
+ :port => Mongo::Connection::DEFAULT_PORT
+ })
+ end
+
def db
@db ||= (super || connect!)
end

0 comments on commit 4da2992

Please sign in to comment.