Module: Moped::BSON::Extensions::Regexp::ClassMethods

Included in:
Regexp
Defined in:
lib/moped/bson/extensions/regexp.rb

Instance Method Summary collapse

Instance Method Details

#__bson_load__(io) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/moped/bson/extensions/regexp.rb', line 19

def __bson_load__(io)
  source = io.gets(NULL_BYTE).from_utf8_binary.chop!
  options = 0
  while (option = io.readbyte) != 0
    case option
    when 105 # 'i'
      options |= ::Regexp::IGNORECASE
    when 109, 115 # 'm', 's'
      options |= ::Regexp::MULTILINE
    when 120 # 'x'
      options |= ::Regexp::EXTENDED
    end
  end
  new(source, options)
end