Module: Rack::Cache::Purge::Base

Included in:
Rack::Cache::Purge
Defined in:
lib/rack/cache/purge/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



5
6
7
# File 'lib/rack/cache/purge/base.rb', line 5

def app
  @app
end

#purgerObject (readonly)

Returns the value of attribute purger.



5
6
7
# File 'lib/rack/cache/purge/base.rb', line 5

def purger
  @purger
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rack/cache/purge/base.rb', line 12

def call(env)
  purger = Purger.new(env)
  status, headers, body = app.call(env.merge(PURGER_HEADER => purger))

  # TODO we probably should remove the headers here but i can't figure out
  # how to get the middlewares correctly pushed to the rails middleware stack
  # purger.purge(headers.delete(PURGE_HEADER)) if headers.key?(PURGE_HEADER)

  purger.purge(headers[PURGE_HEADER]) if headers.key?(PURGE_HEADER)
  [status, headers, body]
end

#initialize(app, options = {}) ⇒ Object



7
8
9
10
# File 'lib/rack/cache/purge/base.rb', line 7

def initialize(app, options = {})
  self.class.allow_http_purge! if options[:allow_http_purge]
  @app = app
end