This class has dubious semantics and we only have it so that people can
write params[:key] instead of params['key'] and they get
the same value for both keys.
lazy_load_hooks allows rails to lazily load a lot of components and thus
making the app boot faster. Because of this feature now there is no need to
require ActiveRecord::Base
at boot time purely to apply configuration. Instead a hook is registered
that applies configuration once ActiveRecord::Base is loaded. Here
ActiveRecord::Base is used
as example but this feature can be applied elsewhere too.
Here is an example where on_load method is called
to register a hook.
initializer "active_record.initialize_timezone" do
ActiveSupport.on_load(:active_record) do
self.time_zone_aware_attributes = true
self.default_timezone = :utc
end
end
When the entirety of activerecord/lib/active_record/base.rb has
been evaluated then run_load_hooks is
invoked. The very last line of
activerecord/lib/active_record/base.rb is:
ActiveSupport.run_load_hooks(:active_record, ActiveRecord::Base)
Usually key value pairs are handled something like this:
h = {}
h[:boy] = 'John'
h[:girl] = 'Mary'
h[:boy]
h[:girl]
Using OrderedOptions, the
above code could be reduced to:
h = ActiveSupport::OrderedOptions.new
h.boy = 'John'
h.girl = 'Mary'
h.boy
h.girl
The TimeZone class serves as a wrapper around
TZInfo::Timezone instances. It allows us to do the following:
-
Limit the set of zones provided by TZInfo to a meaningful subset of 142
zones.
-
Retrieve and display zones with a friendlier name (e.g., “Eastern Time (US & Canada)” instead of
“America/New_York”).
-
Lazily load TZInfo::Timezone instances only when they’re needed.
-
Create ActiveSupport::TimeWithZone
instances via TimeZone’s local,
parse, at and now methods.
If you set config.time_zone in the Rails Application,
you can access this TimeZone object via
Time.zone:
class Application < Rails::Application
config.time_zone = "Eastern Time (US & Canada)"
end
Time.zone
Time.zone.name
Time.zone.now
The version of TZInfo bundled with Active Support only includes the
definitions necessary to support the zones defined by the TimeZone class. If you need to use zones that
aren’t defined by TimeZone, you’ll need
to install the TZInfo gem (if a recent version of the gem is installed
locally, this will be used instead of the bundled version.)
XmlMini Nokogiri implementation using a SAX-based parser
XmlMini ReXML implementation
XmlMini Nokogiri implementation
XmlMini LibXML implementation using a SAX-based parser
XmlMini JRuby JDOM implementation
Some code from jeremymcanally’s “pending”
github.com/jeremymcanally/pending/tree/master
Constants
FrozenObjectError = RUBY_VERSION < '1.9' ? TypeError : RuntimeError
Attributes
Show files where this module is defined (84 files)
activesupport/lib/active_support.rb
activesupport/lib/active_support/test_case.rb
activesupport/lib/active_support/string_inquirer.rb
activesupport/lib/active_support/cache/strategy/local_cache.rb
activesupport/lib/active_support/cache/file_store.rb
activesupport/lib/active_support/cache/null_store.rb
activesupport/lib/active_support/cache/mem_cache_store.rb
activesupport/lib/active_support/cache/memory_store.rb
activesupport/lib/active_support/time_with_zone.rb
activesupport/lib/active_support/multibyte/unicode.rb
activesupport/lib/active_support/multibyte/exceptions.rb
activesupport/lib/active_support/multibyte/chars.rb
activesupport/lib/active_support/multibyte/utils.rb
activesupport/lib/active_support/rescuable.rb
activesupport/lib/active_support/notifications.rb
activesupport/lib/active_support/message_encryptor.rb
activesupport/lib/active_support/json/variable.rb
activesupport/lib/active_support/json/encoding.rb
activesupport/lib/active_support/json/decoding.rb
activesupport/lib/active_support/dependencies.rb
activesupport/lib/active_support/backtrace_cleaner.rb
activesupport/lib/active_support/gzip.rb
activesupport/lib/active_support/memoizable.rb
activesupport/lib/active_support/version.rb
activesupport/lib/active_support/file_update_checker.rb
activesupport/lib/active_support/concern.rb
activesupport/lib/active_support/descendants_tracker.rb
activesupport/lib/active_support/deprecation.rb
activesupport/lib/active_support/configurable.rb
activesupport/lib/active_support/ordered_hash.rb
activesupport/lib/active_support/hash_with_indifferent_access.rb
activesupport/lib/active_support/dependencies/autoload.rb
activesupport/lib/active_support/buffered_logger.rb
activesupport/lib/active_support/xml_mini.rb
activesupport/lib/active_support/time/autoload.rb
activesupport/lib/active_support/lazy_load_hooks.rb
activesupport/lib/active_support/base64.rb
activesupport/lib/active_support/inflections.rb
activesupport/lib/active_support/tagged_logging.rb
activesupport/lib/active_support/ordered_options.rb
activesupport/lib/active_support/basic_object.rb
activesupport/lib/active_support/cache.rb
activesupport/lib/active_support/core_ext/exception.rb
activesupport/lib/active_support/core_ext/string/output_safety.rb
activesupport/lib/active_support/callbacks.rb
activesupport/lib/active_support/duration.rb
activesupport/lib/active_support/values/time_zone.rb
activesupport/lib/active_support/log_subscriber.rb
activesupport/lib/active_support/option_merger.rb
activesupport/lib/active_support/benchmarkable.rb
activesupport/lib/active_support/log_subscriber/test_helper.rb
activesupport/lib/active_support/message_verifier.rb
activesupport/lib/active_support/xml_mini/nokogirisax.rb
activesupport/lib/active_support/xml_mini/rexml.rb
activesupport/lib/active_support/xml_mini/nokogiri.rb
activesupport/lib/active_support/xml_mini/libxmlsax.rb
activesupport/lib/active_support/xml_mini/jdom.rb
activesupport/lib/active_support/xml_mini/libxml.rb
activesupport/lib/active_support/deprecation/reporting.rb
activesupport/lib/active_support/deprecation/behaviors.rb
activesupport/lib/active_support/deprecation/method_wrappers.rb
activesupport/lib/active_support/deprecation/proxy_wrappers.rb
activesupport/lib/active_support/file_watcher.rb
activesupport/lib/active_support/notifications/fanout.rb
activesupport/lib/active_support/notifications/instrumenter.rb
activesupport/lib/active_support/time.rb
activesupport/lib/active_support/inflector/methods.rb
activesupport/lib/active_support/inflector/transliterate.rb
activesupport/lib/active_support/inflector/inflections.rb
activesupport/lib/active_support/railtie.rb
activesupport/lib/active_support/multibyte.rb
activesupport/lib/active_support/testing/pending.rb
activesupport/lib/active_support/testing/performance/ruby.rb
activesupport/lib/active_support/testing/performance/rubinius.rb
activesupport/lib/active_support/testing/performance/jruby.rb
activesupport/lib/active_support/testing/performance/ruby/yarv.rb
activesupport/lib/active_support/testing/performance/ruby/mri.rb
activesupport/lib/active_support/testing/deprecation.rb
activesupport/lib/active_support/testing/assertions.rb
activesupport/lib/active_support/testing/setup_and_teardown.rb
activesupport/lib/active_support/testing/declarative.rb
activesupport/lib/active_support/testing/performance.rb
activesupport/lib/active_support/testing/isolation.rb
activesupport/bin/generate_tables