Module: MultiJson Deprecated

Defined in:
lib/multi_json/legacy_constant.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.

This file is loaded last by the multi_json entry point so the forwarder snapshot below sees the complete MultiJSON public API, including the deprecated aliases defined in deprecated.rb.

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



50
51
52
53
54
# File 'lib/multi_json/legacy_constant.rb', line 50

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