Class: Ki::Middleware::DocGenerator
- Inherits:
-
HamlCompiler
- Object
- HamlCompiler
- Ki::Middleware::DocGenerator
- Includes:
- BaseMiddleware
- Defined in:
- lib/ki/middleware/doc_generator.rb
Direct Known Subclasses
Instance Method Summary collapse
Methods included from BaseMiddleware
Instance Method Details
#call(env) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/ki/middleware/doc_generator.rb', line 6 def call(env) req = BaseRequest.new env if custom_check(req) if view_exists?(req) html = render_haml_file view_path(req) else html = render_haml_file custom_view_path end Rack::Response.new(html).finish else @app.call env end end |
#custom_check(req) ⇒ Object
20 21 22 |
# File 'lib/ki/middleware/doc_generator.rb', line 20 def custom_check(req) req.doc? end |
#custom_view_path ⇒ Object
24 25 26 |
# File 'lib/ki/middleware/doc_generator.rb', line 24 def custom_view_path File.join(File.dirname(__FILE__), '..', 'views', 'instadoc.haml') end |