Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Instead of forcing safety on by default, let the connection settings …

…specify it. Add w, pool_size, and ssl option defaults to the config.
  • Loading branch information...
commit 7a653a8066e3d3e3d25148aee37a5997a801f91d 1 parent 68373a5
@cheald cheald authored
View
6 lib/mongo_mapper/plugins/modifiers.rb
@@ -79,19 +79,19 @@ def criteria_and_keys_from_args(args)
criteria = args[0]
updates = args[1]
options = args[2]
- upgrade_legacy_safe_usage(options)
else
criteria, (updates, options) = args.partition { |a| !a.is_a?(Hash) }
criteria = { :id => criteria }
end
+ upgrade_legacy_safe_usage!(options)
[criteria_hash(criteria).to_hash, updates, options]
end
- def upgrade_legacy_safe_usage(options)
+ def upgrade_legacy_safe_usage!(options)
if options and options.key?(:safe)
- options.delete :safe
options.merge! Utils.get_safe_options(options)
+ options.delete :safe
end
end
end
View
3  lib/mongo_mapper/utils.rb
@@ -1,8 +1,9 @@
module MongoMapper
module Utils
def self.get_safe_options(options)
+ return {} unless options and options.key? :safe
safe = options[:safe]
- safe = {:w => 1} if safe == true or safe.nil?
+ safe = {:w => 1} if safe == true
safe = {:w => 0} if safe == false
safe = {:w => safe} if safe.is_a? Fixnum
safe
View
5 lib/rails/generators/mongo_mapper/config/templates/mongo.yml 100644 → 100755
@@ -1,6 +1,10 @@
defaults: &defaults
host: 127.0.0.1
port: 27017
+ w: 1
+ pool_size: 1
+ slave_ok: false
+ ssl: false
development:
<<: *defaults
@@ -9,6 +13,7 @@ development:
test:
<<: *defaults
database: <%= database_name || app_name %>_test
+ w: 0
# set these environment variables on your prod server
production:
Please sign in to comment.
Something went wrong with that request. Please try again.