From 9fd8173942b9ac863be01486790829b02e3e07b4 Mon Sep 17 00:00:00 2001 From: Chris Hengl Date: Thu, 14 Aug 2014 15:14:41 +0200 Subject: [PATCH 1/2] allow multiple write options including wtimeout --- lib/moped/session.rb | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/moped/session.rb b/lib/moped/session.rb index 1ada2b4..194ed02 100644 --- a/lib/moped/session.rb +++ b/lib/moped/session.rb @@ -172,12 +172,24 @@ def logout # Setup validation of allowed write concern options. # # @since 2.0.0 - option(:write).allow({ w: Optionable.any(Integer) }, { "w" => Optionable.any(Integer) }) - option(:write).allow({ w: Optionable.any(String) }, { "w" => Optionable.any(String) }) - option(:write).allow({ j: true }, { "j" => true }) - option(:write).allow({ j: false }, { "j" => false }) - option(:write).allow({ fsync: true }, { "fsync" => true }) - option(:write).allow({ fsync: false }, { "fsync" => false }) + option(:write).allow(Optionable.any(Hash)) + + class WriteOption + include Optionable + + option(:w).allow(Optionable.any(Integer)) + option('w').allow(Optionable.any(Integer)) + option(:j).allow(true, false) + option('j').allow(true, false) + option(:fsync).allow(true, false) + option('fsync').allow(true, false) + option(:wtimeout).allow(Optionable.any(Integer)) + option('wtimeout').allow(Optionable.any(Integer)) + + def initialize(opts) + validate_strict(opts) + end + end # Setup validation of allowed read preference options. # @@ -258,6 +270,7 @@ def logout # @since 1.0.0 def initialize(seeds, options = {}) validate_strict(options) + WriteOption.new(options[:write]) @options = options @cluster = Cluster.new(seeds, options) end From c61da96aac1ed7d220d306e6d6f127f8dad57901 Mon Sep 17 00:00:00 2001 From: Chris Hengl Date: Mon, 18 Aug 2014 09:31:55 +0200 Subject: [PATCH 2/2] allow w:string --- lib/moped/session.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/moped/session.rb b/lib/moped/session.rb index 194ed02..1e537ae 100644 --- a/lib/moped/session.rb +++ b/lib/moped/session.rb @@ -179,6 +179,8 @@ class WriteOption option(:w).allow(Optionable.any(Integer)) option('w').allow(Optionable.any(Integer)) + option(:w).allow(Optionable.any(String)) + option('w').allow(Optionable.any(String)) option(:j).allow(true, false) option('j').allow(true, false) option(:fsync).allow(true, false)