class Cache

Public Class Methods

new(instance, method) click to toggle source
# File lib/paymo/cache.rb, line 3
def initialize(instance, method)
  @data     = {}
  @instance = instance
  @method   = method
end

Public Instance Methods

get(key) click to toggle source
# File lib/paymo/cache.rb, line 9
def get(key)
  begin
    @data.fetch(key)
  rescue KeyError
    set(key)
    get(key)
  end
end
set(key) click to toggle source
# File lib/paymo/cache.rb, line 18
def set(key)
  @data.store key, value(key)
end

Private Instance Methods

value(key) click to toggle source
# File lib/paymo/cache.rb, line 24
def value(key)
  @instance.get_info(key).send @method
end