Class: Rack::Prerender

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/prerender.rb,
lib/rack/prerender/fetcher.rb,
lib/rack/prerender/version.rb,
lib/rack/prerender/constraint.rb

Defined Under Namespace

Classes: Constraint, Fetcher

Constant Summary collapse

VERSION =
'1.6.2.1'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Prerender.



10
11
12
13
14
# File 'lib/rack/prerender.rb', line 10

def initialize(app, options = {})
  @app        = app
  @constraint = Constraint.new(options)
  @fetcher    = Fetcher.new(options)
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



8
9
10
# File 'lib/rack/prerender.rb', line 8

def app
  @app
end

#constraintObject (readonly)

Returns the value of attribute constraint.



8
9
10
# File 'lib/rack/prerender.rb', line 8

def constraint
  @constraint
end

#fetcherObject (readonly)

Returns the value of attribute fetcher.



8
9
10
# File 'lib/rack/prerender.rb', line 8

def fetcher
  @fetcher
end

Instance Method Details

#call(env) ⇒ Object



16
17
18
# File 'lib/rack/prerender.rb', line 16

def call(env)
  constraint.matches?(env) && fetcher.call(env) || app.call(env)
end