def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?)
      buffer.put_cstring(source)
      buffer.put_cstring(bson_options)
    end
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?)
      buffer.put_cstring(source)
      buffer.put_cstring(bson_options)
    end
Get the regular expression as encoded BSON.

 @example Get the regular expression as encoded BSON.
   %r{\d+}.to_bson

 @note From the BSON spec: The first cstring is the regex pattern,
   the second is the regex options string. Options are identified
   by characters, which must be stored in alphabetical order.
   Valid options are 'i' for case insensitive matching,
   'm' for multiline matching, 'x' for verbose mode,
   'l' to make \w, \W, etc. locale dependent,
   's' for dotall mode ('.' matches everything),
   and 'u' to make \w, \W, etc. match unicode.

 @param [ BSON::ByteBuffer ] buffer The byte buffer to append to.
 @param [ true, false ] validating_keys

 @return [ BSON::ByteBuffer ] The buffer with the encoded object.

 @see http://bsonspec.org/#/specification

 @since 2.0.0