Module: MultiXML::OptionsNormalization Private
- Defined in:
- lib/multi_xml/options_normalization.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Helpers for normalizing the options hash passed to parse
Lives in its own module (rather than inside ParseSupport, which is
mixed into MultiXML's singleton class) so self inside these
methods is OptionsNormalization rather than MultiXML. That
separation is what lets mutation testing distinguish
MultiXML.warn_deprecation_once(...) from
self.warn_deprecation_once(...).
Class Method Summary collapse
-
.normalize_symbolize_option(options) ⇒ Hash
private
Translate the deprecated
:symbolize_keysoption to:symbolize_names.
Class Method Details
.normalize_symbolize_option(options) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Translate the deprecated :symbolize_keys option to :symbolize_names
Matches Ruby stdlib's JSON.parse and sister library MultiJSON
naming. Emits a one-time deprecation warning on first encounter
of :symbolize_keys. When both names appear together (unusual
— only possible if the caller explicitly set both), the canonical
:symbolize_names value wins and :symbolize_keys is
silently dropped.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/multi_xml/options_normalization.rb', line 28 def self.normalize_symbolize_option() return unless .key?(:symbolize_keys) MultiXML.warn_deprecation_once(:symbolize_keys_option, "The :symbolize_keys option is deprecated and will be removed in v1.0. Use :symbolize_names instead.") new_opts = .dup legacy_value = new_opts.delete(:symbolize_keys) new_opts[:symbolize_names] = legacy_value unless new_opts.key?(:symbolize_names) new_opts end |