Class: ActiveSupport::Dependencies::ClassCache
- Inherits:
-
Object
- Object
- ActiveSupport::Dependencies::ClassCache
- Defined in:
- activesupport/lib/active_support/dependencies.rb
Defined Under Namespace
Classes: Getter
Instance Method Summary (collapse)
- - (Object) [](key) (also: #get)
- - (Object) []=(key, value)
- - (Object) clear!
- - (Boolean) empty?
-
- (ClassCache) initialize
constructor
A new instance of ClassCache.
- - (Boolean) key?(key)
- - (Object) new(name)
- - (Object) store(name)
Constructor Details
- (ClassCache) initialize
A new instance of ClassCache
527 528 529 |
# File 'activesupport/lib/active_support/dependencies.rb', line 527 def initialize @store = Hash.new { |h, k| h[k] = Inflector.constantize(k) } end |
Instance Method Details
- (Object) [](key) Also known as: get
547 548 549 550 551 |
# File 'activesupport/lib/active_support/dependencies.rb', line 547 def [](key) key = key.name if key.respond_to?(:name) @store[key] end |
- (Object) []=(key, value)
539 540 541 542 543 544 545 |
# File 'activesupport/lib/active_support/dependencies.rb', line 539 def []=(key, value) return unless key.respond_to?(:name) raise(ArgumentError, 'anonymous classes cannot be cached') if key.name.blank? @store[key.name] = value end |
- (Object) clear!
576 577 578 |
# File 'activesupport/lib/active_support/dependencies.rb', line 576 def clear! @store.clear end |
- (Boolean) empty?
531 532 533 |
# File 'activesupport/lib/active_support/dependencies.rb', line 531 def empty? @store.empty? end |
- (Boolean) key?(key)
535 536 537 |
# File 'activesupport/lib/active_support/dependencies.rb', line 535 def key?(key) @store.key?(key) end |
- (Object) new(name)
565 566 567 568 |
# File 'activesupport/lib/active_support/dependencies.rb', line 565 def new(name) self[name] = name Getter.new(name) end |
- (Object) store(name)
571 572 573 574 |
# File 'activesupport/lib/active_support/dependencies.rb', line 571 def store(name) self[name] = name self end |