Sha256: 4e0724081057468f9362330221a3137940eebc4b5e4b40d0305de10df52f000f

Contents?: true

Size: 954 Bytes

Versions: 22

Compression:

Stored size: 954 Bytes

Contents

module Origin

  # This is a smart hash for use with options and selectors.
  class Smash < Hash

    private

    # Get the normalized value for the key. If localization is in play the
    # current locale will be appended to the key in MongoDB dot notation.
    #
    # FIXME (Did).
    # This version DOES NOT USE ::I18n.locale directly.
    # See the localized.rb file for more explanation.
    #
    # @api private
    #
    # @example Get the normalized key name.
    #   smash.normalized_key("field", serializer)
    #
    # @param [ String ] name The name of the field.
    # @param [ Object ] serializer The optional field serializer.
    #
    # @return [ String ] The normalized key.
    #
    # @since 1.0.0
    def normalized_key(name, serializer)
      # serializer && serializer.localized? ? "#{name}.#{::I18n.locale}" : name
      serializer && serializer.localized? ? "#{name}.#{::Mongoid::Fields::I18n.locale}" : name
    end

  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
custom_fields-2.12.1 lib/custom_fields/extensions/origin/smash.rb
custom_fields-2.12.0 lib/custom_fields/extensions/origin/smash.rb
custom_fields-2.10.0 lib/custom_fields/extensions/origin/smash.rb
custom_fields-2.10.0.rc1 lib/custom_fields/extensions/origin/smash.rb
custom_fields-2.10.0.beta3 lib/custom_fields/extensions/origin/smash.rb
custom_fields-2.10.0.beta2 lib/custom_fields/extensions/origin/smash.rb
custom_fields-2.9.0 lib/custom_fields/extensions/origin/smash.rb
custom_fields-2.9.0.rc2 lib/custom_fields/extensions/origin/smash.rb
custom_fields-2.9.0.rc1 lib/custom_fields/extensions/origin/smash.rb
custom_fields-2.8.0 lib/custom_fields/extensions/origin/smash.rb
custom_fields-2.7.0 lib/custom_fields/extensions/origin/smash.rb
custom_fields-2.7.0.rc1 lib/custom_fields/extensions/origin/smash.rb
custom_fields-2.6.0 lib/custom_fields/extensions/origin/smash.rb
custom_fields-2.5.0 lib/custom_fields/extensions/origin/smash.rb
custom_fields-2.5.0.rc1 lib/custom_fields/extensions/origin/smash.rb
custom_fields-2.4.0.rc8 lib/custom_fields/extensions/origin/smash.rb
custom_fields-2.4.0.rc7 lib/custom_fields/extensions/origin/smash.rb
custom_fields-2.4.0.rc6 lib/custom_fields/extensions/origin/smash.rb
custom_fields-2.4.0.rc5 lib/custom_fields/extensions/origin/smash.rb
custom_fields-2.4.0.rc4 lib/custom_fields/extensions/origin/smash.rb