Class: Racket::Application
- Inherits:
-
Object
- Object
- Racket::Application
- Defined in:
- lib/racket/application.rb
Overview
Racket main application class.
Class Method Summary collapse
-
.call(env) ⇒ Array
Called whenever Rack sends a request to the application.
-
.default(reboot = false) ⇒ Class
Initializes a new Racket::Application object with default options.
-
.dev_mode? ⇒ true|false
Returns whether the application runs in dev mode.
-
.get_route(controller, action, params) ⇒ String
Returns a route to the specified controller/action/parameter combination.
-
.inform_all(message, level = :info) ⇒ Object
Sends a message to the logger.
-
.inform_dev(message, level = :debug) ⇒ Object
Sends a message to the logger, but only if the application is running in dev mode.
-
.options ⇒ Hash
Returns options for the currently running Racket::Application.
-
.reload ⇒ nil
Reloads the application, making any changes to the controller configuration visible to the application.
-
.require(*args) ⇒ nil
Requires a file using the current application directory as a base path.
-
.router ⇒ Racket::Router
Returns the router associated with the currenntly running Racket::Application.
-
.serve_static_file(env) ⇒ Array|nil
Serves a static file (if Racket is configured to serve static files).
-
.using(options, reboot = false) ⇒ Class
Initializes a new Racket::Application object with options specified by
options. -
.view_cache ⇒ ViewCache
Returns the view cache of the currently running application.
Class Method Details
.call(env) ⇒ Array
Called whenever Rack sends a request to the application.
59 60 61 |
# File 'lib/racket/application.rb', line 59 def self.call(env) application.call(env.dup) end |
.default(reboot = false) ⇒ Class
Initializes a new Racket::Application object with default options.
113 114 115 |
# File 'lib/racket/application.rb', line 113 def self.default(reboot = false) init({}, reboot) end |
.dev_mode? ⇒ true|false
Returns whether the application runs in dev mode.
95 96 97 |
# File 'lib/racket/application.rb', line 95 def self.dev_mode? @options[:mode] == :dev end |
.get_route(controller, action, params) ⇒ String
Returns a route to the specified controller/action/parameter combination.
105 106 107 |
# File 'lib/racket/application.rb', line 105 def self.get_route(controller, action, params) @router.get_route(controller, action, params) end |
.inform_all(message, level = :info) ⇒ Object
Sends a message to the logger.
131 132 133 |
# File 'lib/racket/application.rb', line 131 def self.inform_all(, level = :info) inform(, level) end |
.inform_dev(message, level = :debug) ⇒ Object
Sends a message to the logger, but only if the application is running in dev mode.
140 141 142 |
# File 'lib/racket/application.rb', line 140 def self.inform_dev(, level = :debug) (inform(, level) if dev_mode?) && nil end |
.options ⇒ Hash
Returns options for the currently running Racket::Application.
188 189 190 |
# File 'lib/racket/application.rb', line 188 def self. @options end |
.reload ⇒ nil
Reloads the application, making any changes to the controller configuration visible to the application.
196 197 198 199 |
# File 'lib/racket/application.rb', line 196 def self.reload setup_routes @view_cache = nil end |
.require(*args) ⇒ nil
Requires a file using the current application directory as a base path.
205 206 207 |
# File 'lib/racket/application.rb', line 205 def self.require(*args) (::Kernel.require Utils.build_path(*args)) && nil end |
.router ⇒ Racket::Router
Returns the router associated with the currenntly running Racket::Application.
212 213 214 |
# File 'lib/racket/application.rb', line 212 def self.router @router end |
.serve_static_file(env) ⇒ Array|nil
Serves a static file (if Racket is configured to serve static files).
220 221 222 223 |
# File 'lib/racket/application.rb', line 220 def self.serve_static_file(env) return nil if @static_server.nil? @static_server.call(env) end |
.using(options, reboot = false) ⇒ Class
Initializes a new Racket::Application object with options specified by options.
248 249 250 |
# File 'lib/racket/application.rb', line 248 def self.using(, reboot = false) init(, reboot) end |