Module: MultiJson::AdapterSelector Private

Extended by:
AdapterSelector
Included in:
MultiJson, AdapterSelector
Defined in:
lib/multi_json/adapter_selector.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.

Handles adapter discovery, loading, and selection

Adapters can be specified as:

  • Symbol/String: adapter name (e.g., :oj, “json_gem”)

  • Module: adapter class directly

  • nil/false: use default adapter

Constant Summary collapse

ALIASES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Alternate spellings for adapter names

{"jrjackson" => "jr_jackson"}.freeze
LOADERS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Strategy lambdas for loading adapters based on specification type

{
  Module => ->(adapter, _selector) { adapter },
  String => ->(name, selector) { selector.send(:load_adapter_by_name, name) },
  Symbol => ->(name, selector) { selector.send(:load_adapter_by_name, name.to_s) },
  NilClass => ->(_adapter, selector) { selector.send(:load_adapter, selector.default_adapter) },
  FalseClass => ->(_adapter, selector) { selector.send(:load_adapter, selector.default_adapter) }
}.freeze

Instance Method Summary collapse

Instance Method Details

#default_adapterSymbol

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.

Returns the default adapter to use

Examples:

AdapterSelector.default_adapter  #=> :oj

Returns:

  • (Symbol)

    adapter name



31
32
33
# File 'lib/multi_json/adapter_selector.rb', line 31

def default_adapter
  @default_adapter ||= detect_best_adapter
end