Class: Hanami::Configuration Private
- Inherits:
-
Object
- Object
- Hanami::Configuration
- Defined in:
- lib/hanami/configuration.rb,
lib/hanami/configuration/app.rb,
lib/hanami/configuration/middleware.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: App, Middleware
Instance Method Summary collapse
- #apps ⇒ Object private
-
#early_hints(value = nil) ⇒ Object
private
Setup Early Hints feature.
-
#environment(name) ⇒ Object
private
Configure settings for the current environment.
-
#initialize(&blk) ⇒ Configuration
constructor
private
A new instance of Configuration.
-
#logger(*options) ⇒ Object
private
Configure logger.
-
#mailer(&blk) ⇒ Object
private
Configure mailer.
- #mailer_settings ⇒ Object private
- #middleware ⇒ Object private
-
#model(&blk) ⇒ Object
private
Configure database.
-
#mount(app, options) ⇒ Object
private
Mount a Hanami::Application or a Rack app.
- #mounted ⇒ Object private
Constructor Details
#initialize(&blk) ⇒ Configuration
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Configuration.
13 14 15 16 |
# File 'lib/hanami/configuration.rb', line 13 def initialize(&blk) @settings = Concurrent::Map.new instance_eval(&blk) end |
Instance Method Details
#apps ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
142 143 144 145 146 |
# File 'lib/hanami/configuration.rb', line 142 def apps mounted.each_pair do |klass, app| yield(app) if klass <= Hanami::Application end end |
#early_hints(value = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Setup Early Hints feature
132 133 134 135 136 137 138 |
# File 'lib/hanami/configuration.rb', line 132 def early_hints(value = nil) if value.nil? settings.fetch(:early_hints, false) else settings[:early_hints] = value end end |
#environment(name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Configure settings for the current environment
206 207 208 |
# File 'lib/hanami/configuration.rb', line 206 def environment(name) yield if ENV['HANAMI_ENV'] == name.to_s end |
#logger(*options) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Configure logger
178 179 180 181 182 183 184 |
# File 'lib/hanami/configuration.rb', line 178 def logger(*) if .empty? settings.fetch(:logger, nil) else settings[:logger] = end end |
#mailer(&blk) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Configure mailer
87 88 89 |
# File 'lib/hanami/configuration.rb', line 87 def mailer(&blk) mailer_settings.push(blk) if block_given? end |
#mailer_settings ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
93 94 95 |
# File 'lib/hanami/configuration.rb', line 93 def mailer_settings settings.fetch_or_store(:mailers, []) end |
#middleware ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
111 112 113 |
# File 'lib/hanami/configuration.rb', line 111 def middleware settings.fetch_or_store(:middleware, Configuration::Middleware.new) end |
#model(&blk) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Configure database
60 61 62 63 64 65 66 |
# File 'lib/hanami/configuration.rb', line 60 def model(&blk) if block_given? settings.put_if_absent(:model, blk) else settings.fetch(:model) end end |
#mount(app, options) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Mount a Hanami::Application or a Rack app
37 38 39 |
# File 'lib/hanami/configuration.rb', line 37 def mount(app, ) mounted[app] = App.new(app, ) end |
#mounted ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
99 100 101 |
# File 'lib/hanami/configuration.rb', line 99 def mounted settings.fetch_or_store(:mounted, {}) end |