123456789_123456789_123456789_123456789_123456789_

Module: ActiveSupport

Relationships & Source Files
Namespace Children
Modules:
Classes:
Exceptions:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Defined in: activesupport/lib/active_support/inflections.rb,
activesupport/lib/active_support.rb,
activesupport/lib/active_support/array_inquirer.rb,
activesupport/lib/active_support/backtrace_cleaner.rb,
activesupport/lib/active_support/benchmarkable.rb,
activesupport/lib/active_support/cache.rb,
activesupport/lib/active_support/callbacks.rb,
activesupport/lib/active_support/concern.rb,
activesupport/lib/active_support/configurable.rb,
activesupport/lib/active_support/current_attributes.rb,
activesupport/lib/active_support/dependencies.rb,
activesupport/lib/active_support/deprecation.rb,
activesupport/lib/active_support/descendants_tracker.rb,
activesupport/lib/active_support/digest.rb,
activesupport/lib/active_support/duration.rb,
activesupport/lib/active_support/encrypted_configuration.rb,
activesupport/lib/active_support/encrypted_file.rb,
activesupport/lib/active_support/evented_file_update_checker.rb,
activesupport/lib/active_support/execution_wrapper.rb,
activesupport/lib/active_support/executor.rb,
activesupport/lib/active_support/file_update_checker.rb,
activesupport/lib/active_support/gem_version.rb,
activesupport/lib/active_support/gzip.rb,
activesupport/lib/active_support/hash_with_indifferent_access.rb,
activesupport/lib/active_support/key_generator.rb,
activesupport/lib/active_support/lazy_load_hooks.rb,
activesupport/lib/active_support/log_subscriber.rb,
activesupport/lib/active_support/logger.rb,
activesupport/lib/active_support/logger_thread_safe_level.rb,
activesupport/lib/active_support/message_encryptor.rb,
activesupport/lib/active_support/message_verifier.rb,
activesupport/lib/active_support/multibyte.rb,
activesupport/lib/active_support/notifications.rb,
activesupport/lib/active_support/number_helper.rb,
activesupport/lib/active_support/option_merger.rb,
activesupport/lib/active_support/ordered_hash.rb,
activesupport/lib/active_support/ordered_options.rb,
activesupport/lib/active_support/per_thread_registry.rb,
activesupport/lib/active_support/proxy_object.rb,
activesupport/lib/active_support/railtie.rb,
activesupport/lib/active_support/reloader.rb,
activesupport/lib/active_support/rescuable.rb,
activesupport/lib/active_support/security_utils.rb,
activesupport/lib/active_support/string_inquirer.rb,
activesupport/lib/active_support/subscriber.rb,
activesupport/lib/active_support/tagged_logging.rb,
activesupport/lib/active_support/test_case.rb,
activesupport/lib/active_support/time.rb,
activesupport/lib/active_support/time_with_zone.rb,
activesupport/lib/active_support/version.rb,
activesupport/lib/active_support/xml_mini.rb,
activesupport/lib/active_support/cache/file_store.rb,
activesupport/lib/active_support/cache/mem_cache_store.rb,
activesupport/lib/active_support/cache/memory_store.rb,
activesupport/lib/active_support/cache/null_store.rb,
activesupport/lib/active_support/cache/redis_cache_store.rb,
activesupport/lib/active_support/cache/strategy/local_cache.rb,
activesupport/lib/active_support/cache/strategy/local_cache_middleware.rb,
activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb,
activesupport/lib/active_support/concurrency/share_lock.rb,
activesupport/lib/active_support/core_ext/marshal.rb,
activesupport/lib/active_support/core_ext/big_decimal/conversions.rb,
activesupport/lib/active_support/core_ext/hash/conversions.rb,
activesupport/lib/active_support/core_ext/object/json.rb,
activesupport/lib/active_support/core_ext/object/try.rb,
activesupport/lib/active_support/core_ext/range/compare_range.rb,
activesupport/lib/active_support/core_ext/range/each.rb,
activesupport/lib/active_support/core_ext/range/include_time_with_zone.rb,
activesupport/lib/active_support/core_ext/string/output_safety.rb,
activesupport/lib/active_support/dependencies/autoload.rb,
activesupport/lib/active_support/dependencies/interlock.rb,
activesupport/lib/active_support/deprecation/behaviors.rb,
activesupport/lib/active_support/deprecation/constant_accessor.rb,
activesupport/lib/active_support/deprecation/instance_delegator.rb,
activesupport/lib/active_support/deprecation/method_wrappers.rb,
activesupport/lib/active_support/deprecation/proxy_wrappers.rb,
activesupport/lib/active_support/deprecation/reporting.rb,
activesupport/lib/active_support/duration/iso8601_parser.rb,
activesupport/lib/active_support/duration/iso8601_serializer.rb,
activesupport/lib/active_support/inflector/inflections.rb,
activesupport/lib/active_support/inflector/methods.rb,
activesupport/lib/active_support/inflector/transliterate.rb,
activesupport/lib/active_support/json/decoding.rb,
activesupport/lib/active_support/json/encoding.rb,
activesupport/lib/active_support/log_subscriber/test_helper.rb,
activesupport/lib/active_support/messages/metadata.rb,
activesupport/lib/active_support/messages/rotation_configuration.rb,
activesupport/lib/active_support/messages/rotator.rb,
activesupport/lib/active_support/multibyte/chars.rb,
activesupport/lib/active_support/multibyte/unicode.rb,
activesupport/lib/active_support/notifications/fanout.rb,
activesupport/lib/active_support/notifications/instrumenter.rb,
activesupport/lib/active_support/number_helper/number_converter.rb,
activesupport/lib/active_support/number_helper/number_to_currency_converter.rb,
activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb,
activesupport/lib/active_support/number_helper/number_to_human_converter.rb,
activesupport/lib/active_support/number_helper/number_to_human_size_converter.rb,
activesupport/lib/active_support/number_helper/number_to_percentage_converter.rb,
activesupport/lib/active_support/number_helper/number_to_phone_converter.rb,
activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb,
activesupport/lib/active_support/number_helper/rounding_helper.rb,
activesupport/lib/active_support/testing/assertions.rb,
activesupport/lib/active_support/testing/constant_lookup.rb,
activesupport/lib/active_support/testing/declarative.rb,
activesupport/lib/active_support/testing/deprecation.rb,
activesupport/lib/active_support/testing/file_fixtures.rb,
activesupport/lib/active_support/testing/isolation.rb,
activesupport/lib/active_support/testing/method_call_assertions.rb,
activesupport/lib/active_support/testing/setup_and_teardown.rb,
activesupport/lib/active_support/testing/stream.rb,
activesupport/lib/active_support/testing/tagged_logging.rb,
activesupport/lib/active_support/testing/time_helpers.rb,
activesupport/lib/active_support/values/time_zone.rb,
activesupport/lib/active_support/xml_mini/jdom.rb,
activesupport/lib/active_support/xml_mini/libxml.rb,
activesupport/lib/active_support/xml_mini/libxmlsax.rb,
activesupport/lib/active_support/xml_mini/nokogiri.rb,
activesupport/lib/active_support/xml_mini/nokogirisax.rb,
activesupport/lib/active_support/xml_mini/rexml.rb,
railties/lib/rails/test_help.rb

Overview

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 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.

Class Attribute Summary

  • .parse_json_times (also: #parse_json_times) rw

    Look for and parse json strings that look like ISO 8601 times.

Class Method Summary

  • .eager_load!
  • .gem_version

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

  • .version

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

LazyLoadHooks - Extended

on_load

Declares a block that will be executed when a ::Rails component is fully loaded.

run_load_hooks

Autoload - Extended

Instance Attribute Summary

Class Attribute Details

.parse_json_times (rw) Also known as: #parse_json_times

Look for and parse json strings that look like ISO 8601 times.

[ GitHub ]

  
# File 'activesupport/lib/active_support/json/decoding.rb', line 9

mattr_accessor :parse_json_times

Class Method Details

.eager_load!

[ GitHub ]

  
# File 'activesupport/lib/active_support.rb', line 78

def self.eager_load!
  super

  NumberHelper.eager_load!
end

.gem_version

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

[ GitHub ]

  
# File 'activesupport/lib/active_support/gem_version.rb', line 5

def self.gem_version
  Gem::Version.new VERSION::STRING
end

.version

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

[ GitHub ]

  
# File 'activesupport/lib/active_support/version.rb', line 7

def self.version
  gem_version
end

Instance Attribute Details

#escape_html_entities_in_json (rw)

[ GitHub ]

  
# File 'activesupport/lib/active_support/json/encoding.rb', line 8

delegate :use_standard_json_time_format, :use_standard_json_time_format=,
  :time_precision, :time_precision=,
  :escape_html_entities_in_json, :escape_html_entities_in_json=,
  :json_encoder, :json_encoder=,
  to: :'ActiveSupport::JSON::Encoding'

#json_encoder (rw)

[ GitHub ]

  
# File 'activesupport/lib/active_support/json/encoding.rb', line 8

delegate :use_standard_json_time_format, :use_standard_json_time_format=,
  :time_precision, :time_precision=,
  :escape_html_entities_in_json, :escape_html_entities_in_json=,
  :json_encoder, :json_encoder=,
  to: :'ActiveSupport::JSON::Encoding'

#parse_json_times (rw)

[ GitHub ]

  
# File 'activesupport/lib/active_support/json/decoding.rb', line 9

mattr_accessor :parse_json_times

#time_precision (rw)

[ GitHub ]

  
# File 'activesupport/lib/active_support/json/encoding.rb', line 8

delegate :use_standard_json_time_format, :use_standard_json_time_format=,
  :time_precision, :time_precision=,
  :escape_html_entities_in_json, :escape_html_entities_in_json=,
  :json_encoder, :json_encoder=,
  to: :'ActiveSupport::JSON::Encoding'

#use_standard_json_time_format (rw)

[ GitHub ]

  
# File 'activesupport/lib/active_support/json/encoding.rb', line 8

delegate :use_standard_json_time_format, :use_standard_json_time_format=,
  :time_precision, :time_precision=,
  :escape_html_entities_in_json, :escape_html_entities_in_json=,
  :json_encoder, :json_encoder=,
  to: :'ActiveSupport::JSON::Encoding'