Class: Racket::Application
- Inherits:
-
Object
- Object
- Racket::Application
- Defined in:
- lib/racket/application.rb
Overview
Racket main application class.
Instance Attribute Summary collapse
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
Class Method Summary collapse
-
.default ⇒ Class
Initializes a new Racket::Application object with default settings.
-
.using(settings) ⇒ Class
Initializes a new Racket::Application object with settings specified by
settings
.
Instance Method Summary collapse
-
#call(env) ⇒ Array
Called whenever Rack sends a request to the application.
-
#dev_mode? ⇒ true|false
Returns whether the application runs in dev mode.
-
#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.
-
#initialize(settings = {}) ⇒ Class
constructor
Initializes the Racket application.
- #kernel_require ⇒ Object
-
#require(*args) ⇒ nil
Requires a file using the current application directory as a base path.
Constructor Details
#initialize(settings = {}) ⇒ Class
Initializes the Racket application.
43 44 45 46 47 |
# File 'lib/racket/application.rb', line 43 def initialize(settings = {}) @registry = Utils::Application::RegistryBuilder.new(settings).registry @registry.handler_stack # Makes sure all plugins and helpers are loaded before any controllers load_controllers end |
Instance Attribute Details
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
37 38 39 |
# File 'lib/racket/application.rb', line 37 def registry @registry end |
Class Method Details
.default ⇒ Class
Initializes a new Racket::Application object with default settings.
25 26 27 |
# File 'lib/racket/application.rb', line 25 def self.default new end |
.using(settings) ⇒ Class
Initializes a new Racket::Application object with settings specified by settings
.
33 34 35 |
# File 'lib/racket/application.rb', line 33 def self.using(settings) new(settings) end |
Instance Method Details
#call(env) ⇒ Array
Called whenever Rack sends a request to the application.
53 54 55 |
# File 'lib/racket/application.rb', line 53 def call(env) @registry.handler_stack.call(env.dup) end |
#dev_mode? ⇒ true|false
Returns whether the application runs in dev mode.
60 61 62 |
# File 'lib/racket/application.rb', line 60 def dev_mode? @registry.application_settings.mode == :dev end |
#inform_all(message, level = :info) ⇒ Object
Sends a message to the logger.
69 70 71 |
# File 'lib/racket/application.rb', line 69 def inform_all(, level = :info) @registry.application_logger.inform_all(, level) end |
#inform_dev(message, level = :debug) ⇒ Object
Sends a message to the logger, but only if the application is running in dev mode.
78 79 80 |
# File 'lib/racket/application.rb', line 78 def inform_dev(, level = :debug) @registry.application_logger.inform_dev(, level) end |
#kernel_require ⇒ Object
82 |
# File 'lib/racket/application.rb', line 82 alias kernel_require require |
#require(*args) ⇒ nil
Requires a file using the current application directory as a base path.
88 89 90 |
# File 'lib/racket/application.rb', line 88 def require(*args) (kernel_require @registry.utils.build_path(*args)) && nil end |