Module: MultiXml Deprecated

Defined in:
lib/multi_xml.rb

Overview

Deprecated.

Use MultiXML (all-caps) instead. Will be removed in v1.0.

Backward-compatible alias for the legacy MultiXml constant name

Downstream code that still writes MultiXml.parse(...) or rescue MultiXml::ParseError continues to work, but emits a one-time deprecation warning pointing at MultiXML. The module forwards every method call to MultiXML via MultiXml.method_missing and resolves constant access via MultiXml.const_missing, so both dotted calls and :: constant lookups (including rescue clauses) route through the canonical module.

Class Method Summary collapse

Class Method Details

.const_missing(name) ⇒ Object

Resolve missing constants to their MultiXML counterparts

The lookup is performed with inherit: false so a stray top-level ::ParseError constant in the host process (Racc defines one when Nokogiri is loaded) is correctly ignored. Enables rescue MultiXml::ParseError and MultiXml::Parsers::Ox to keep working during the deprecation cycle.

Examples:

MultiXml::Parsers::Ox  # returns MultiXML::Parsers::Ox

Parameters:

  • name (Symbol)

    constant name

Returns:

  • (Object)

    the resolved constant from MultiXML



212
213
214
215
216
# File 'lib/multi_xml.rb', line 212

def const_missing(name)
  ::MultiXML.warn_deprecation_once(:multi_xml_constant,
    "The MultiXml constant is deprecated and will be removed in v1.0. Use MultiXML instead.")
  ::MultiXML.const_get(name, false)
end

.method_missing(name, *args, **kwargs, &block) ⇒ Object

Forward method calls to MultiXML, emitting a one-time warning

rubocop:disable Naming/BlockForwarding, Style/ArgumentsForwarding

Examples:

MultiXml.parse("<a>1</a>")  # delegates to MultiXML.parse

Returns:

  • (Object)

    the delegated call's return value



176
177
178
179
180
181
182
183
184
# File 'lib/multi_xml.rb', line 176

def method_missing(name, *args, **kwargs, &block)
  ::MultiXML.warn_deprecation_once(:multi_xml_constant,
    "The MultiXml constant is deprecated and will be removed in v1.0. Use MultiXML instead.")
  if ::MultiXML.respond_to?(name)
    ::MultiXML.public_send(name, *args, **kwargs, &block)
  else
    super
  end
end

.respond_to_missing?(name, include_private) ⇒ Boolean

Respond to any method MultiXML responds to

Examples:

MultiXml.respond_to?(:parse)  #=> true

Parameters:

  • name (Symbol)

    method name

  • include_private (Boolean)

    include private methods

Returns:

  • (Boolean)

    true if MultiXML responds to the method



195
196
197
# File 'lib/multi_xml.rb', line 195

def respond_to_missing?(name, include_private)
  ::MultiXML.respond_to?(name, include_private)
end