method

convert_key

rails latest stable - Class: Rails::Application::NonSymbolAccessDeprecatedHash

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v6.0.0) is shown here.

convert_key(key)
public

No documentation available.

# File railties/lib/rails/application.rb, line 628
          def convert_key(key)
            unless key.kind_of?(Symbol)
              ActiveSupport::Deprecation.warn(<<~MESSAGE.squish)
                Accessing hashes returned from config_for by non-symbol keys
                is deprecated and will be removed in Rails 6.1.
                Use symbols for access instead.
              MESSAGE

              key = key.to_sym
            end

            key
          end

          def convert_value(value, options = {}) # :doc:
            if value.is_a? Hash
              if options[:for] == :to_hash
                value.to_hash
              else
                self.class.new(value)
              end
            elsif value.is_a?(Array)
              if options[:for] != :assignment || value.frozen?
                value = value.dup
              end
              value.map! { |e| convert_value(e, options) }
            else
              value
            end
          end
      end