Module: BSON::Regexp::ClassMethods

Defined in:
lib/bson/regexp.rb

Overview

Class-level methods to be added to the Regexp class.

Since:

  • 2.0.0

Instance Method Summary collapse

Instance Method Details

#from_bson(buffer, **_) ⇒ Regexp

Note:

If the argument cannot be parsed, an exception will be raised and the argument will be left in an undefined state. The caller must explicitly call ‘rewind` on the buffer before trying to parse it again.

Deserialize the regular expression from BSON.

Parameters:

  • buffer (ByteBuffer)

    The byte buffer.

  • opts (Hash)

    a customizable set of options

Returns:

  • (Regexp)

    The decoded regular expression.

See Also:

Since:

  • 2.0.0



265
266
267
268
269
# File 'lib/bson/regexp.rb', line 265

def from_bson(buffer, **_)
  pattern = buffer.get_cstring
  options = buffer.get_cstring
  Raw.new(pattern, options)
end