Class: Application

Inherits:
Rack::Builder
  • Object
show all
Defined in:
lib/yodel/application/application.rb

Instance Method Summary collapse

Constructor Details

#initializeApplication

Returns a new instance of Application.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/yodel/application/application.rb', line 9

def initialize
  super
  
  # boot
  Yodel.config.logger.info "Yodel starting up" if Yodel.env.production?
  Dir.chdir(Yodel.config.sites_root)
  Yodel.load_extensions
  
  # setup middleware
  use Rack::ShowExceptions if Yodel.env.development?
  use ErrorPages
  use Rack::Session::Cookie, key: Yodel.config.session_key, secret: Yodel.config.session_secret
  use Rack::NestedParams
  use Rack::MethodOverride
  use SiteDetector
  use PublicAssets if Yodel.env.development?
  
  # FIXME: for production, load layouts once
  if Yodel.env.production?
    Site.all.each {|site| Layout.reload_layouts(site)}
  end
  
  # initialise a rack endpoint
  run RequestHandler.new
  @app = to_app
  
  # boot complete
  unless Yodel.env.development?
    Yodel.config.logger.info "Yodel startup complete"
  end
end

Instance Method Details

#call(env) ⇒ Object



41
42
43
# File 'lib/yodel/application/application.rb', line 41

def call(env)
  @app.call(env)
end