Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions lib/moped/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,26 @@ 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(: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)
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.
#
Expand Down Expand Up @@ -258,6 +272,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
Expand Down