Module: ActiveSupport::Memoizable::Freezable
- Defined in:
- lib/gems/activesupport-2.2.2/lib/active_support/memoizable.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/gems/activesupport-2.2.2/lib/active_support/memoizable.rb', line 8 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
#freeze_with_memoizable ⇒ Object
16 17 18 19 |
# File 'lib/gems/activesupport-2.2.2/lib/active_support/memoizable.rb', line 16 def freeze_with_memoizable memoize_all unless frozen? freeze_without_memoizable end |
#memoize_all ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gems/activesupport-2.2.2/lib/active_support/memoizable.rb', line 21 def memoize_all methods.each do |m| if m.to_s =~ /^_unmemoized_(.*)/ if method(m).arity == 0 __send__($1) else ivar = MEMOIZED_IVAR.call($1) instance_variable_set(ivar, {}) end end end end |
#unmemoize_all ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/gems/activesupport-2.2.2/lib/active_support/memoizable.rb', line 34 def unmemoize_all methods.each do |m| if m.to_s =~ /^_unmemoized_(.*)/ ivar = MEMOIZED_IVAR.call($1) instance_variable_get(ivar).clear if instance_variable_defined?(ivar) end end end |