Module: Kernel

Defined in:
lib/aws/ses/extensions.rb

Overview

:stopdoc:

Instance Method Summary collapse

Instance Method Details

#__called_from__Object



7
8
9
# File 'lib/aws/ses/extensions.rb', line 7

def __called_from__
  caller[1][/`([^']+)'/, 1]
end

#__method__(depth = 0) ⇒ Object



3
4
5
# File 'lib/aws/ses/extensions.rb', line 3

def __method__(depth = 0)
  caller[depth][/`([^']+)'/, 1]
end

#expirable_memoize(reload = false, storage = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/aws/ses/extensions.rb', line 11

def expirable_memoize(reload = false, storage = nil)
  current_method = RUBY_VERSION > '1.8.7' ? __called_from__ : __method__(1)
  storage = "@#{storage || current_method}"
  if reload 
    instance_variable_set(storage, nil)
  else
    if cache = instance_variable_get(storage)
      return cache
    end
  end
  instance_variable_set(storage, yield)
end