Module: MultiJson Deprecated
- Defined in:
- lib/multi_json.rb
Overview
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“. The module forwards every method call to MultiJSON via MultiJson.method_missing and resolves constant access via MultiJson.const_missing, so both dotted calls and “::“ constant lookups (including rescue clauses) route through the canonical module.
Class Method Summary collapse
-
.const_missing(name) ⇒ Object
Resolve missing constants to their MultiJSON counterparts.
-
.method_missing(name, *args, **kwargs, &block) ⇒ Object
Forward method calls to MultiJSON, emitting a one-time warning.
-
.respond_to_missing?(name, include_private) ⇒ Boolean
Respond to any method MultiJSON responds to.
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.
332 333 334 335 336 |
# File 'lib/multi_json.rb', line 332 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 |
.method_missing(name, *args, **kwargs, &block) ⇒ Object
Forward method calls to MultiJSON, emitting a one-time warning
Uses explicit “*args, **kwargs, &block“ forwarding because mutant’s AST structure table on the current parser version does not yet recognize “…“ forwarding nodes, so the module would crash mutation analysis. The rubocop exclusions below document that intent.
rubocop:disable Naming/BlockForwarding, Style/ArgumentsForwarding
298 299 300 301 302 303 304 305 306 |
# File 'lib/multi_json.rb', line 298 def method_missing(name, *args, **kwargs, &block) ::MultiJSON.warn_deprecation_once(:multi_json_constant, "The MultiJson constant is deprecated and will be removed in v2.0. Use MultiJSON instead.") if ::MultiJSON.respond_to?(name) ::MultiJSON.public_send(name, *args, **kwargs, &block) else super end end |