module Lite::Memoize::Alias::InstanceMethods
Public Instance Methods
clear_cache(*method_names)
click to toggle source
# File lib/lite/memoize/alias.rb, line 29 def clear_cache(*method_names) memoized_structs(method_names).each do |struct| next unless instance_variable_defined?(struct.ivar) remove_instance_variable(struct.ivar) end end
Also aliased as: clear, flush_cache
memoize_all(*method_names)
click to toggle source
# File lib/lite/memoize/alias.rb, line 19 def memoize_all(*method_names) memoized_structs(method_names).each do |struct| if struct.arity.zero? __send__(struct.memoized_method) else instance_variable_set(struct.ivar, {}) end end end
memoized_structs(names)
click to toggle source
# File lib/lite/memoize/alias.rb, line 11 def memoized_structs(names) ref_obj = self.class.respond_to?(:class_eval) ? singleton_class : self structs = ref_obj.all_memoized_structs return structs if names.empty? structs.select { |s| names.include?(s.memoized_method) } end