Class: Mongo::WriteConcern::Base
- Inherits:
-
Object
- Object
- Mongo::WriteConcern::Base
- Defined in:
- lib/mongo/write_concern/base.rb
Overview
Defines common behavior for write concerns.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#options ⇒ Hash
readonly
The write concern options.
Instance Method Summary collapse
-
#initialize(options) ⇒ Base
constructor
private
Instantiate a new write concern given the options.
Constructor Details
#initialize(options) ⇒ Base
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Instantiate a new write concern given the options.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/mongo/write_concern/base.rb', line 48 def initialize() = Options::Mapper.transform_keys_to_symbols() = Options::Mapper.transform_values_to_strings().freeze if [:w] if [:w] == 0 && [:j] raise Error::InvalidWriteConcern, "Invalid write concern options: :j cannot be true when :w is 0: #{.inspect}" elsif [:w] == 0 && [:fsync] raise Error::InvalidWriteConcern, "Invalid write concern options: :fsync cannot be true when :w is 0: #{.inspect}" elsif [:w].is_a?(Integer) && [:w] < 0 raise Error::InvalidWriteConcern, "Invalid write concern options: :w cannot be negative (#{[:w]}): #{.inspect}" end end if [:journal] raise Error::InvalidWriteConcern, "Invalid write concern options: use :j for journal: #{.inspect}" end @options = end |
Instance Attribute Details
#options ⇒ Hash (readonly)
Returns The write concern options.
27 28 29 |
# File 'lib/mongo/write_concern/base.rb', line 27 def @options end |