Module: ActiveSupport::Memoizable::InstanceMethods
- Defined in:
- activesupport/lib/active_support/memoizable.rb
Class Method Summary (collapse)
Instance Method Summary (collapse)
- - (Object) flush_cache(*syms)
- - (Object) freeze_with_memoizable
- - (Object) memoize_all
- - (Object) prime_cache(*syms)
- - (Object) unmemoize_all
Class Method Details
+ (Object) included(base)
11 12 13 14 15 16 17 |
# File 'activesupport/lib/active_support/memoizable.rb', line 11 def self.included(base) base.class_eval do unless base.method_defined?(:freeze_without_memoizable) alias_method_chain :freeze, :memoizable end end end |
Instance Method Details
- (Object) flush_cache(*syms)
47 48 49 50 51 52 53 54 55 56 |
# File 'activesupport/lib/active_support/memoizable.rb', line 47 def flush_cache(*syms) syms.each do |sym| (methods + private_methods + protected_methods).each do |m| if m.to_s =~ /^_unmemoized_(#{sym.to_s.gsub(/\?\Z/, '\?')})/ ivar = ActiveSupport::Memoizable.memoized_ivar_for($1) instance_variable_get(ivar).clear if instance_variable_defined?(ivar) end end end end |
- (Object) freeze_with_memoizable
19 20 21 22 |
# File 'activesupport/lib/active_support/memoizable.rb', line 19 def freeze_with_memoizable memoize_all unless frozen? freeze_without_memoizable end |
- (Object) memoize_all
24 25 26 |
# File 'activesupport/lib/active_support/memoizable.rb', line 24 def memoize_all prime_cache ".*" end |
- (Object) prime_cache(*syms)
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'activesupport/lib/active_support/memoizable.rb', line 32 def prime_cache(*syms) syms.each do |sym| methods.each do |m| if m.to_s =~ /^_unmemoized_(#{sym})/ if method(m).arity == 0 __send__($1) else ivar = ActiveSupport::Memoizable.memoized_ivar_for($1) instance_variable_set(ivar, {}) end end end end end |
- (Object) unmemoize_all
28 29 30 |
# File 'activesupport/lib/active_support/memoizable.rb', line 28 def unmemoize_all flush_cache ".*" end |