Class: Racket::Application
- Inherits:
-
Object
- Object
- Racket::Application
- Defined in:
- lib/racket/application.rb
Overview
Racket main application class.
Class Attribute Summary collapse
-
.router ⇒ Object
readonly
Returns the value of attribute router.
-
.settings ⇒ Object
readonly
Returns the value of attribute settings.
Class Method Summary collapse
-
.apply_settings(settings) ⇒ Object
Applies settings.
-
.call(env) ⇒ Array
Called whenever Rack sends a request to the application.
-
.default ⇒ Class
Initializes a new Racket::Application object with default settings.
-
.dev_mode? ⇒ true|false
Returns whether the application runs in dev mode.
-
.get_route(controller, action = nil, *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.
-
.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.
-
.serve_static_file(env) ⇒ Array|nil
Serves a static file (if Racket is configured to serve static files).
-
.using(settings) ⇒ Class
Initializes a new Racket::Application object with settings specified by
settings. -
.view_manager ⇒ Racket::ViewManager
Returns the view cache of the currently running application.
Class Attribute Details
.router ⇒ Object (readonly)
Returns the value of attribute router.
25 26 27 |
# File 'lib/racket/application.rb', line 25 def router @router end |
.settings ⇒ Object (readonly)
Returns the value of attribute settings.
25 26 27 |
# File 'lib/racket/application.rb', line 25 def settings @settings end |
Class Method Details
.apply_settings(settings) ⇒ Object
Applies settings.
37 38 39 40 |
# File 'lib/racket/application.rb', line 37 def self.apply_settings(settings) fail 'Application has already been initialized!' if @settings @settings = Settings::Application.new(settings) end |
.call(env) ⇒ Array
Called whenever Rack sends a request to the application.
52 53 54 |
# File 'lib/racket/application.rb', line 52 def self.call(env) application.call(env.dup) end |
.default ⇒ Class
Initializes a new Racket::Application object with default settings.
76 77 78 |
# File 'lib/racket/application.rb', line 76 def self.default init end |
.dev_mode? ⇒ true|false
Returns whether the application runs in dev mode.
59 60 61 |
# File 'lib/racket/application.rb', line 59 def self.dev_mode? @settings.mode == :dev end |
.get_route(controller, action = nil, *params) ⇒ String
Returns a route to the specified controller/action/parameter combination.
69 70 71 |
# File 'lib/racket/application.rb', line 69 def self.get_route(controller, action = nil, *params) @router.get_route(controller, action, params) end |
.inform_all(message, level = :info) ⇒ Object
Sends a message to the logger.
95 96 97 |
# File 'lib/racket/application.rb', line 95 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.
104 105 106 |
# File 'lib/racket/application.rb', line 104 def self.inform_dev(, level = :debug) (inform(, level) if dev_mode?) && nil end |
.reload ⇒ nil
Reloads the application, making any changes to the controller configuration visible to the application.
153 154 155 156 |
# File 'lib/racket/application.rb', line 153 def self.reload setup_routes @view_manager = nil end |
.require(*args) ⇒ nil
Requires a file using the current application directory as a base path.
162 163 164 |
# File 'lib/racket/application.rb', line 162 def self.require(*args) (::Kernel.require Utils.build_path(*args)) && nil end |
.serve_static_file(env) ⇒ Array|nil
Serves a static file (if Racket is configured to serve static files).
170 171 172 |
# File 'lib/racket/application.rb', line 170 def self.serve_static_file(env) @static_server ? @static_server.call(env) : nil end |
.using(settings) ⇒ Class
Initializes a new Racket::Application object with settings specified by settings.
197 198 199 |
# File 'lib/racket/application.rb', line 197 def self.using(settings) init(settings) end |
.view_manager ⇒ Racket::ViewManager
Returns the view cache of the currently running application.
204 205 206 |
# File 'lib/racket/application.rb', line 204 def self.view_manager @view_manager ||= ViewManager.new(@settings.layout_dir, @settings.view_dir) end |