module ActiveSupport
Ruby on Rails 5.2.8.1
Since v2.2.3The 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
Modules
- ActiveSupport::Autoload
- ActiveSupport::Benchmarkable
- ActiveSupport::Cache
- ActiveSupport::Callbacks
- ActiveSupport::Concern
- ActiveSupport::Concurrency
- ActiveSupport::Configurable
- ActiveSupport::Dependencies
- ActiveSupport::DescendantsTracker
- ActiveSupport::Gzip
- ActiveSupport::Inflector
- ActiveSupport::JSON
- ActiveSupport::LazyLoadHooks
- ActiveSupport::Messages
- ActiveSupport::Multibyte
- ActiveSupport::Notifications
- ActiveSupport::NumberHelper
- ActiveSupport::NumericWithFormat
- ActiveSupport::PerThreadRegistry
- ActiveSupport::RangeWithFormat
- ActiveSupport::Rescuable
- ActiveSupport::SecurityUtils
- ActiveSupport::TaggedLogging
- ActiveSupport::Testing
- ActiveSupport::VERSION
- ActiveSupport::XmlMini
- ActiveSupport::XmlMini_LibXMLSAX
- ActiveSupport::XmlMini_NokogiriSAX
Classes
- ActiveSupport::ArrayInquirer
- ActiveSupport::BacktraceCleaner
- ActiveSupport::CachingKeyGenerator
- ActiveSupport::CurrentAttributes
- ActiveSupport::Deprecation
- ActiveSupport::DeprecationException
- ActiveSupport::Duration
- ActiveSupport::EncryptedConfiguration
- ActiveSupport::EncryptedFile
- ActiveSupport::EventedFileUpdateChecker
- ActiveSupport::ExecutionWrapper
- ActiveSupport::Executor
- ActiveSupport::FileUpdateChecker
- ActiveSupport::HashWithIndifferentAccess
- ActiveSupport::InheritableOptions
- ActiveSupport::KeyGenerator
- ActiveSupport::Logger
- ActiveSupport::LogSubscriber
- ActiveSupport::MessageEncryptor
- ActiveSupport::MessageVerifier
- ActiveSupport::OrderedHash
- ActiveSupport::OrderedOptions
- ActiveSupport::ProxyObject
- ActiveSupport::Reloader
- ActiveSupport::SafeBuffer
- ActiveSupport::StringInquirer
- ActiveSupport::Subscriber
- ActiveSupport::TestCase
- ActiveSupport::TimeWithZone
- ActiveSupport::TimeZone
- ActiveSupport::XMLConverter
Extends
Methods (defined here)
- self. eager_load!
- self. gem_version
- self. to_time_preserves_timezone
- self. to_time_preserves_timezone=
- self. version
Methods (inherited)
From ActiveSupport::Autoload (6)
- # autoload
- # autoload_at
- # autoload_under
- # autoloads
- # eager_autoload
- # eager_load!