Module: MultiJson Deprecated

Defined in:
lib/multi_json.rb

Overview

Deprecated.

Use MultiJSON (all-caps) instead. Will be removed in v2.0.

Backward-compatible alias for the legacy “MultiJson“ constant name

Downstream code that still writes “MultiJson.parse(…)“ or “rescue MultiJson::ParseError“ continues to work, but emits a one-time deprecation warning pointing at “MultiJSON“. Each public method on MultiJSON gets an explicit forwarder defined on this module, and constant access resolves via MultiJson.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 MultiJSON counterparts

Enables “rescue MultiJson::ParseError“ and “MultiJson::Adapters::Oj“ to keep working during the deprecation cycle.

Examples:

MultiJson::ParseError  # returns MultiJSON::ParseError

Parameters:

  • name (Symbol)

    constant name

Returns:

  • (Object)

    the resolved constant from MultiJSON



314
315
316
317
318
# File 'lib/multi_json.rb', line 314

def const_missing(name)
  ::MultiJSON.warn_deprecation_once(:multi_json_constant,
    "The MultiJson constant is deprecated and will be removed in v2.0. Use MultiJSON instead.")
  ::MultiJSON.const_get(name)
end