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, output_dir = nil) ⇒ Rack

Returns a new instance of Rack.



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

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

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
# File 'lib/chuusha.rb', line 15

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