Method: Mongo::Options::Mapper#transform_values_to_strings

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

#transform_values_to_strings(options) ⇒ Hash

Coverts all the symbol values to strings.

Examples:

Convert all option symbol values to strings.

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

Parameters:

  • options (Hash)

    The options to transform.

Returns:

  • (Hash)

    The transformed options.

Since:

  • 2.0.0



121
122
123
124
125
126
# File 'lib/mongo/options/mapper.rb', line 121

def transform_values_to_strings(options)
  options.reduce({}) do |transformed, (key, value)|
    transformed[key] = value.is_a?(Symbol) ? value.to_s : value
    transformed
  end
end