The JSON gem adds a few modules to Ruby core classes containing :to_json definition, overwriting their default behavior. That said, we need to define the basic to_json method in all of them, otherwise they will always use to_json gem implementation, which is backwards incompatible in several cases (for instance, the JSON implementation for Hash does not work) with inheritance and consequently classes as ActiveSupport::OrderedHash cannot be serialized to json.

On the other hand, we should avoid conflict with ::JSON.{generate,dump}(obj). Unfortunately, the JSON gem's encoder relies on its own to_json implementation to encode objects. Since it always passes a ::JSON::State object as the only argument to to_json, we can detect that and forward the calls to the original to_json method.

It should be noted that when using ::JSON.{generate,dump} directly, ActiveSupport's encoder is bypassed completely. This means that as_json won't be invoked and the JSON gem will simply ignore any options it does not natively understand. This also means that ::JSON.{generate,dump} should give exactly the same results with or without active support.

Namespace
Methods
E
G
H
O
R
T
V
Class Public methods
eager_load!()
# File activesupport/lib/active_support.rb, line 74
def self.eager_load!
  super

  NumberHelper.eager_load!
end
execute_hook(base, options, block)
# File activesupport/lib/active_support/lazy_load_hooks.rb, line 34
def self.execute_hook(base, options, block)
  if options[:yield]
    block.call(base)
  else
    base.instance_eval(&block)
  end
end
gem_version()

Returns the version of the currently loaded Active Support as a Gem::Version.

# File activesupport/lib/active_support/gem_version.rb, line 3
def self.gem_version
  Gem::Version.new VERSION::STRING
end
halt_callback_chains_on_return_false()
# File activesupport/lib/active_support.rb, line 82
def self.halt_callback_chains_on_return_false
  Callbacks.halt_and_display_warning_on_return_false
end
halt_callback_chains_on_return_false=(value)
# File activesupport/lib/active_support.rb, line 86
def self.halt_callback_chains_on_return_false=(value)
  Callbacks.halt_and_display_warning_on_return_false = value
end
on_load(name, options = {}, &block)
# File activesupport/lib/active_support/lazy_load_hooks.rb, line 26
def self.on_load(name, options = {}, &block)
  @loaded[name].each do |base|
    execute_hook(base, options, block)
  end

  @load_hooks[name] << [block, options]
end
run_load_hooks(name, base = Object)
# File activesupport/lib/active_support/lazy_load_hooks.rb, line 42
def self.run_load_hooks(name, base = Object)
  @loaded[name] << base
  @load_hooks[name].each do |hook, options|
    execute_hook(base, options, hook)
  end
end
to_time_preserves_timezone()
# File activesupport/lib/active_support.rb, line 90
def self.to_time_preserves_timezone
  DateAndTime::Compatibility.preserve_timezone
end
to_time_preserves_timezone=(value)
# File activesupport/lib/active_support.rb, line 94
def self.to_time_preserves_timezone=(value)
  DateAndTime::Compatibility.preserve_timezone = value
end
version()

Returns the version of the currently loaded ActiveSupport as a Gem::Version

# File activesupport/lib/active_support/version.rb, line 5
def self.version
  gem_version
end