class ActiveSupport::Dependencies::ClassCache - activesupport-4.2.4 Documentation

# class ActiveSupport::Dependencies::ClassCache

### Public Class Methods

new() click to toggle source

    # File lib/active_support/dependencies.rb, line 552
    def initialize
      @store = ThreadSafe::Cache.new
    end

### Public Instance Methods

[](key)
Alias for: get
clear!() click to toggle source

    # File lib/active_support/dependencies.rb, line 582
    def clear!
      @store.clear
    end

empty?() click to toggle source

    # File lib/active_support/dependencies.rb, line 556
    def empty?
      @store.empty?
    end

get(key) click to toggle source

    # File lib/active_support/dependencies.rb, line 564
    def get(key)
      key = key.name if key.respond_to?(:name)
      @store[key] ||= Inflector.constantize(key)
    end

Also aliased as: []
key?(key) click to toggle source

    # File lib/active_support/dependencies.rb, line 560
    def key?(key)
      @store.key?(key)
    end

safe_get(key) click to toggle source

    # File lib/active_support/dependencies.rb, line 570
    def safe_get(key)
      key = key.name if key.respond_to?(:name)
      @store[key] ||= Inflector.safe_constantize(key)
    end

store(klass) click to toggle source

    # File lib/active_support/dependencies.rb, line 575
    def store(klass)
      return self unless klass.respond_to?(:name)
      raise(ArgumentError, 'anonymous classes cannot be cached') if klass.name.empty?
      @store[klass.name] = klass
      self
    end