module InfoparkComponentCache::DelayedGuard::ClassMethods

Public Instance Methods

delay(method_name, options) click to toggle source
# File lib/infopark_component_cache/delayed_guard.rb, line 48
def delay(method_name, options)
  expiration = options[:for]
  return unless expiration

  # allow to overwrite the delays
  alias_method :"delayed_#{method_name}", method_name unless method_defined?(:"delayed_#{method_name}")
  define_method method_name do
    value = delayed_value(method_name)
    if still_delayed?(method_name)
      value
    else
      delay_value(method_name, send(:"delayed_#{method_name}"), expiration)
    end
  end
end