Module: AWS::SES::ExpirableMemoize::InstanceMethods
Instance Method Summary collapse
- #__called_from__ ⇒ Object
- #__method__(depth = 0) ⇒ Object
- #expirable_memoize(reload = false, storage = nil) ⇒ Object
Instance Method Details
#__called_from__ ⇒ Object
10 11 12 |
# File 'lib/aws/ses/expirable_memoize.rb', line 10 def __called_from__ caller[1][/`([^']+)'/, 1] end |
#__method__(depth = 0) ⇒ Object
6 7 8 |
# File 'lib/aws/ses/expirable_memoize.rb', line 6 def __method__(depth = 0) caller[depth][/`([^']+)'/, 1] end |
#expirable_memoize(reload = false, storage = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/aws/ses/expirable_memoize.rb', line 14 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 |