Module: Tins::Memoize::CacheMethods

Defined in:
lib/tins/memoize.rb

Instance Method Summary collapse

Instance Method Details

#__memoize_cache__Object

Return the cache object.



7
8
9
# File 'lib/tins/memoize.rb', line 7

def __memoize_cache__
  @__memoize_cache__ ||= {}
end

#memoize_apply_visibility(id) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/tins/memoize.rb', line 17

def memoize_apply_visibility(id)
  visibility = instance_eval do
    case
    when private_method_defined?(id)
      :private
    when protected_method_defined?(id)
      :protected
    end
  end
  yield
ensure
  visibility and __send__(visibility, id)
end

#memoize_cache_clearObject

Clear cached values for all methods/functions.



12
13
14
15
# File 'lib/tins/memoize.rb', line 12

def memoize_cache_clear
   __memoize_cache__.clear
  self
end