Class: Chuusha::Rack

Inherits:
Object
  • Object
show all
Defined in:
lib/chuusha.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, root_dir, config = nil) ⇒ Rack

Returns a new instance of Rack.



6
7
8
9
10
11
# File 'lib/chuusha.rb', line 6

def initialize(app, root_dir, config=nil)
  @app      = app
  @root_dir = root_dir
  @config   = Config.new(config)
  cache_everything if @config.cache_on_load?
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
# File 'lib/chuusha.rb', line 13

def call(env)
  renderer = Renderer.new(@config, @root_dir + env["PATH_INFO"])
  return renderer.respond if renderer.template_exists?
  @app.call(env)
end