Class: Nyth::Application
- Inherits:
-
Object
- Object
- Nyth::Application
- Defined in:
- lib/nyth/application.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(root:, app_path: "app") ⇒ Application
constructor
A new instance of Application.
Constructor Details
#initialize(root:, app_path: "app") ⇒ Application
Returns a new instance of Application.
10 11 12 13 |
# File 'lib/nyth/application.rb', line 10 def initialize(root:, app_path: "app") @root = Pathname(root). @content_root = @root.join(app_path) end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/nyth/application.rb', line 15 def call(env) request = Rack::Request.new(env) file = file_for(request.path_info) return not_found unless file&.file? return not_found if partial?(file) file.extname == ".erb" ? html(evaluate_template(file)) : static(file, request) rescue Errno::ENOENT not_found end |