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



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/moped/bson/extensions/regexp.rb', line 7

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