Class: Luneta::Park
- Inherits:
-
Object
- Object
- Luneta::Park
- Defined in:
- lib/luneta/park.rb
Constant Summary collapse
- @@routes =
[]
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(routes) ⇒ Park
constructor
A new instance of Park.
Constructor Details
#initialize(routes) ⇒ Park
Returns a new instance of Park.
32 33 34 |
# File 'lib/luneta/park.rb', line 32 def initialize(routes) @routes = routes end |
Class Method Details
.path {|block| ... } ⇒ Object
26 27 28 |
# File 'lib/luneta/park.rb', line 26 def path(&block) yield block end |
Instance Method Details
#call(env) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/luneta/park.rb', line 36 def call(env) @output = "" @routes.each do |route| match = env['PATH_INFO'].match(route[:path]) if match req = Rack::Request.new(env) template = route[:template] template = Dir.pwd + "/" + template layout_template = route[:layout] layout_template = Dir.pwd + "/" + layout_template res = Rack::Response.new if layout_template layout = Luneta::Template.new(layout_template) @output = layout.render(route[:title], route[:locals]) do Luneta::Template.new(template).render(route[:title], route[:locals]) end else @output = Luneta::Template.new(template).render(route[:title], route[:locals]) end res.write @output res.finish return res end end end |