Class: ImageVise::ExpireAfter

Inherits:
Struct
  • Object
show all
Defined in:
lib/image_vise/operators/expire_after.rb

Overview

Overrides the cache lifetime set in the output headers of the RenderEngine. Can be used to permit the requester to set the caching lifetime, instead of it being a configuration variable in the service performing the rendering

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(seconds:) ⇒ ExpireAfter

Returns a new instance of ExpireAfter.



5
6
7
8
9
10
# File 'lib/image_vise/operators/expire_after.rb', line 5

def initialize(seconds:)
  unless seconds.is_a?(Integer) && seconds > 0
    raise ArgumentError, "the :seconds parameter must be an Integer and must be above 0, but was %s" % seconds.inspect
  end
  super
end

Instance Attribute Details

#secondsObject

Returns the value of attribute seconds

Returns:

  • (Object)

    the current value of seconds



4
5
6
# File 'lib/image_vise/operators/expire_after.rb', line 4

def seconds
  @seconds
end

Instance Method Details

#apply!(_, metadata) ⇒ Object



12
13
14
# File 'lib/image_vise/operators/expire_after.rb', line 12

def apply!(_, )
  [:expire_after_seconds] = seconds
end