Method: Mongo::Options::Mapper#transform_keys_to_strings

Defined in:
lib/mongo/options/mapper.rb

#transform_keys_to_strings(options) ⇒ Hash

Coverts all the keys of the options to strings.

Examples:

Convert all option keys to strings.

Mapper.transform({ :name => 1 })

Parameters:

  • options (Hash)

    The options to transform.

Returns:

  • (Hash)

    The transformed options.

Since:

  • 2.0.0



87
88
89
90
91
92
# File 'lib/mongo/options/mapper.rb', line 87

def transform_keys_to_strings(options)
  options.reduce({}) do |transformed, (key, value)|
    transformed[key.to_s] = value
    transformed
  end
end