Module: ActiveSupport

### Home Classes Methods

### In Files

- lib/active_support/secure_random.rb
- lib/active_support/dependencies.rb
- lib/active_support/ordered_options.rb
- lib/active_support/cache/mem_cache_store.rb
- lib/active_support/cache/synchronized_memory_store.rb
- lib/active_support/cache/compressed_mem_cache_store.rb
- lib/active_support/cache/memory_store.rb
- lib/active_support/cache/file_store.rb
- lib/active_support/cache/strategy/local_cache.rb
- lib/active_support/ordered_hash.rb
- lib/active_support/string_inquirer.rb
- lib/active_support/core_ext/string/output_safety.rb
- lib/active_support/core_ext/exception.rb
- lib/active_support/message_verifier.rb
- lib/active_support/callbacks.rb
- lib/active_support/log_subscriber/test_helper.rb
- lib/active_support/option_merger.rb
- lib/active_support/notifications.rb
- lib/active_support/descendants_tracker.rb
- lib/active_support/inflector/transliterate.rb
- lib/active_support/inflector/methods.rb
- lib/active_support/inflector/inflections.rb
- lib/active_support/values/time_zone.rb
- lib/active_support/test_case.rb
- lib/active_support/dependencies/autoload.rb
- lib/active_support/basic_object.rb
- lib/active_support/time_with_zone.rb
- lib/active_support/hash_with_indifferent_access.rb
- lib/active_support/concern.rb
- lib/active_support/time/autoload.rb
- lib/active_support/testing/declarative.rb
- lib/active_support/testing/performance.rb
- lib/active_support/testing/setup_and_teardown.rb
- lib/active_support/testing/default.rb
- lib/active_support/testing/pending.rb
- lib/active_support/testing/assertions.rb
- lib/active_support/testing/deprecation.rb
- lib/active_support/testing/isolation.rb
- lib/active_support/file_update_checker.rb
- lib/active_support/cache.rb
- lib/active_support/backtrace_cleaner.rb
- lib/active_support/railtie.rb
- lib/active_support/json/backends/jsongem.rb
- lib/active_support/json/backends/yajl.rb
- lib/active_support/json/backends/yaml.rb
- lib/active_support/json/variable.rb
- lib/active_support/json/decoding.rb
- lib/active_support/json/encoding.rb
- lib/active_support/memoizable.rb
- lib/active_support/deprecation.rb
- lib/active_support/deprecation/reporting.rb
- lib/active_support/deprecation/proxy_wrappers.rb
- lib/active_support/deprecation/method_wrappers.rb
- lib/active_support/deprecation/behaviors.rb
- lib/active_support/duration.rb
- lib/active_support/lazy_load_hooks.rb
- lib/active_support/configurable.rb
- lib/active_support/benchmarkable.rb
- lib/active_support/version.rb
- lib/active_support/base64.rb
- lib/active_support/multibyte/exceptions.rb
- lib/active_support/multibyte/utils.rb
- lib/active_support/multibyte/chars.rb
- lib/active_support/multibyte/unicode.rb
- lib/active_support/rescuable.rb
- lib/active_support/message_encryptor.rb
- lib/active_support/inflections.rb
- lib/active_support/multibyte.rb
- lib/active_support/time.rb
- lib/active_support/xml_mini.rb
- lib/active_support/xml_mini/rexml.rb
- lib/active_support/xml_mini/libxmlsax.rb
- lib/active_support/xml_mini/nokogiri.rb
- lib/active_support/xml_mini/jdom.rb
- lib/active_support/xml_mini/nokogirisax.rb
- lib/active_support/xml_mini/libxml.rb
- lib/active_support/buffered_logger.rb
- lib/active_support/notifications/fanout.rb
- lib/active_support/notifications/instrumenter.rb
- lib/active_support/log_subscriber.rb
- lib/active_support/gzip.rb
- lib/active_support.rb

### Namespace

- MODULE ActiveSupport::Autoload
- MODULE ActiveSupport::Base64
- MODULE ActiveSupport::Benchmarkable
- MODULE ActiveSupport::Cache
- MODULE ActiveSupport::Callbacks
- MODULE ActiveSupport::Concern
- MODULE ActiveSupport::Configurable
- MODULE ActiveSupport::Dependencies
- MODULE ActiveSupport::Deprecation
- MODULE ActiveSupport::DescendantsTracker
- MODULE ActiveSupport::Gzip
- MODULE ActiveSupport::Inflector
- MODULE ActiveSupport::JSON
- MODULE ActiveSupport::Memoizable
- MODULE ActiveSupport::Multibyte
- MODULE ActiveSupport::Notifications
- MODULE ActiveSupport::Rescuable
- MODULE ActiveSupport::SecureRandom
- MODULE ActiveSupport::Testing
- MODULE ActiveSupport::XmlMini
- MODULE ActiveSupport::XmlMini_LibXMLSAX
- MODULE ActiveSupport::XmlMini_NokogiriSAX
- CLASS ActiveSupport::BacktraceCleaner
- CLASS ActiveSupport::BasicObject
- CLASS ActiveSupport::BufferedLogger
- CLASS ActiveSupport::Duration
- CLASS ActiveSupport::FileUpdateChecker
- CLASS ActiveSupport::HashWithIndifferentAccess
- CLASS ActiveSupport::InheritableOptions
- CLASS ActiveSupport::LogSubscriber
- CLASS ActiveSupport::MessageEncryptor
- CLASS ActiveSupport::MessageVerifier
- CLASS ActiveSupport::OrderedOptions
- CLASS ActiveSupport::Railtie
- CLASS ActiveSupport::SafeBuffer
- CLASS ActiveSupport::StringInquirer
- CLASS ActiveSupport::TestCase
- CLASS ActiveSupport::TimeWithZone
- CLASS ActiveSupport::TimeZone

### Methods

- ::execute_hook
- ::load_all!
- ::on_load
- ::on_load_all
- ::run_load_hooks

### Class/Module Index

Quicksearch

- ActiveSupport
- ActiveSupport::Autoload
- ActiveSupport::BacktraceCleaner
- ActiveSupport::Base64
- ActiveSupport::BasicObject
- ActiveSupport::Benchmarkable
- ActiveSupport::BufferedLogger
- ActiveSupport::BufferedLogger::Severity
- ActiveSupport::Cache
- ActiveSupport::Cache::CompressedMemCacheStore
- ActiveSupport::Cache::Entry
- ActiveSupport::Cache::FileStore
- ActiveSupport::Cache::MemCacheStore
- ActiveSupport::Cache::MemoryStore
- ActiveSupport::Cache::Store
- ActiveSupport::Cache::Strategy
- ActiveSupport::Cache::Strategy::LocalCache
- ActiveSupport::Cache::Strategy::LocalCache::LocalStore
- ActiveSupport::Cache::SynchronizedMemoryStore
- ActiveSupport::Callbacks
- ActiveSupport::Callbacks::Callback
- ActiveSupport::Callbacks::CallbackChain
- ActiveSupport::Callbacks::ClassMethods
- ActiveSupport::Concern
- ActiveSupport::Configurable
- ActiveSupport::Configurable::ClassMethods
- ActiveSupport::Dependencies
- ActiveSupport::Dependencies::Reference
- ActiveSupport::Dependencies::WatchStack
- ActiveSupport::Deprecation
- ActiveSupport::DescendantsTracker
- ActiveSupport::Duration
- ActiveSupport::FileUpdateChecker
- ActiveSupport::Gzip
- ActiveSupport::Gzip::Stream
- ActiveSupport::HashWithIndifferentAccess
- ActiveSupport::HashWithIndifferentAccess
- ActiveSupport::Inflector
- ActiveSupport::Inflector::Inflections
- ActiveSupport::InheritableOptions
- ActiveSupport::JSON
- ActiveSupport::JSON::Backends
- ActiveSupport::JSON::Backends::JSONGem
- ActiveSupport::JSON::Backends::Yajl
- ActiveSupport::JSON::Backends::Yaml
- ActiveSupport::JSON::Encoding
- ActiveSupport::JSON::Encoding::CircularReferenceError
- ActiveSupport::JSON::Encoding::Encoder
- ActiveSupport::JSON::Variable
- ActiveSupport::LogSubscriber
- ActiveSupport::LogSubscriber::TestHelper
- ActiveSupport::LogSubscriber::TestHelper::MockLogger
- ActiveSupport::Memoizable
- ActiveSupport::Memoizable::InstanceMethods
- ActiveSupport::MessageEncryptor
- ActiveSupport::MessageEncryptor::InvalidMessage
- ActiveSupport::MessageVerifier
- ActiveSupport::MessageVerifier::InvalidSignature
- ActiveSupport::Multibyte
- ActiveSupport::Multibyte::Chars
- ActiveSupport::Multibyte::EncodingError
- ActiveSupport::Multibyte::Unicode
- ActiveSupport::Multibyte::Unicode::Codepoint
- ActiveSupport::Multibyte::Unicode::UnicodeDatabase
- ActiveSupport::Notifications
- ActiveSupport::Notifications::Event
- ActiveSupport::Notifications::Fanout
- ActiveSupport::Notifications::Instrumenter
- ActiveSupport::OrderedOptions
- ActiveSupport::Railtie
- ActiveSupport::Rescuable
- ActiveSupport::Rescuable::ClassMethods
- ActiveSupport::SafeBuffer
- ActiveSupport::SecureRandom
- ActiveSupport::StringInquirer
- ActiveSupport::TestCase
- ActiveSupport::Testing
- ActiveSupport::Testing::Assertions
- ActiveSupport::Testing::Declarative
- ActiveSupport::Testing::Isolation
- ActiveSupport::Testing::Isolation::Forking
- ActiveSupport::Testing::Isolation::MiniTest
- ActiveSupport::Testing::Isolation::Subprocess
- ActiveSupport::Testing::Isolation::TestUnit
- ActiveSupport::Testing::Pending
- ActiveSupport::Testing::Performance
- ActiveSupport::Testing::Performance::Benchmarker
- ActiveSupport::Testing::Performance::Metrics
- ActiveSupport::Testing::Performance::Metrics::Base
- ActiveSupport::Testing::Performance::Metrics::CpuTime
- ActiveSupport::Testing::Performance::Metrics::GcRuns
- ActiveSupport::Testing::Performance::Metrics::GcTime
- ActiveSupport::Testing::Performance::Metrics::Memory
- ActiveSupport::Testing::Performance::Metrics::Objects
- ActiveSupport::Testing::Performance::Metrics::ProcessTime
- ActiveSupport::Testing::Performance::Metrics::Time
- ActiveSupport::Testing::Performance::Metrics::WallTime
- ActiveSupport::Testing::Performance::Performer
- ActiveSupport::Testing::Performance::Profiler
- ActiveSupport::Testing::ProxyTestResult
- ActiveSupport::Testing::RemoteError
- ActiveSupport::Testing::SetupAndTeardown
- ActiveSupport::Testing::SetupAndTeardown::ClassMethods
- ActiveSupport::Testing::SetupAndTeardown::ForClassicTestUnit
- ActiveSupport::Testing::SetupAndTeardown::ForMiniTest
- ActiveSupport::TimeWithZone
- ActiveSupport::TimeZone
- ActiveSupport::XmlMini
- ActiveSupport::XmlMini_LibXMLSAX
- ActiveSupport::XmlMini_LibXMLSAX::HashBuilder
- ActiveSupport::XmlMini_NokogiriSAX
- ActiveSupport::XmlMini_NokogiriSAX::HashBuilder
- Test
- Test::Unit
- Test::Unit::Collector
- Test::Unit::Collector::ObjectSpace
- Object
- Object::HashWithIndifferentAccess
- Object::MissingSourceFile
- ERB
- ERB::Util
- I18n
- I18n::Railtie
- LoadError
- LoadError
- Logger
- Logger::SimpleFormatter
- Array
- Benchmark
- BigDecimal
- Class
- Date
- DateTime
- Enumerable
- FalseClass
- File
- Fixnum
- Float
- Hash
- Integer
- Kernel
- Module
- NameError
- NilClass
- Numeric
- Process
- Range
- Regexp
- String
- Symbol
- Time
- TrueClass

No matching classes.

# ActiveSupport

OrderedHash is namespaced to prevent conflicts with other implementations

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`:

    # application.rb:
    class Application < Rails::Application
      config.time_zone = "Eastern Time (US & Canada)"
    end

    Time.zone       # => #<TimeZone:0x514834...>
    Time.zone.name  # => "Eastern Time (US & Canada)"
    Time.zone.now   # => Sun, 18 May 2008 14:30:44 EDT -04:00

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

This class has dubious semantics and we only have it so that people can write params instead of params and they get the same value for both keys.

A typical module looks like this

    module M
      def self.included(base)
        base.send(:extend, ClassMethods)
        base.send(:include, InstanceMethods)
        scope :foo, :conditions => { :created_at => nil }
      end

      module ClassMethods
        def cm; puts 'I am a class method'; end
      end

      module InstanceMethods
        def im; puts 'I am an instance method'; end
      end
    end

By using `ActiveSupport::Concern` the above module could instead be written as:

    module M
      extend ActiveSupport::Concern

      included do
        scope :foo, :conditions => { :created_at => nil }
      end

      module ClassMethods
        def cm; puts 'I am a class method'; end
      end

      module InstanceMethods
        def im; puts 'I am an instance method'; end
      end
    end

Some code from jeremymcanally’s “pending” github.com/jeremymcanally/pending/tree/master

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)

# XmlMini ReXML implementation

# XmlMini LibXML implementation using a SAX-based parser

# XmlMini Nokogiri implementation

# XmlMini JRuby JDOM implementation

# XmlMini Nokogiri implementation using a SAX-based parser

# XmlMini LibXML implementation

### Constants

Base64
FrozenObjectError
SecureRandom

  Use Ruby’s SecureRandom library if available.

### Attributes

load_all_hooks[RW]

### Public Class Methods

execute_hook(base, options, block) click to toggle source

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

load_all!() click to toggle source

    # File lib/active_support.rb, line 28
    def load_all!; load_all_hooks.each { |hook| hook.call } end

on_load(name, options = {}, &block) click to toggle source

    # File lib/active_support/lazy_load_hooks.rb, line 24
    def self.on_load(name, options = {}, &block)
      if base = @loaded[name]
        execute_hook(base, options, block)
      else
        @load_hooks[name] << [block, options]
      end
    end

on_load_all(&hook) click to toggle source

    # File lib/active_support.rb, line 27
    def on_load_all(&hook) load_all_hooks << hook end

run_load_hooks(name, base = Object) click to toggle source

    # File lib/active_support/lazy_load_hooks.rb, line 40
    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

[Validate]

Generated with the Darkfish Rdoc Generator 2.