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.
139 140 141 142 143 |
# File 'lib/hanami/configuration.rb', line 139 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
129 130 131 132 133 134 135 |
# File 'lib/hanami/configuration.rb', line 129 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
203 204 205 |
# File 'lib/hanami/configuration.rb', line 203 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
175 176 177 178 179 180 181 |
# File 'lib/hanami/configuration.rb', line 175 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
84 85 86 |
# File 'lib/hanami/configuration.rb', line 84 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.
90 91 92 |
# File 'lib/hanami/configuration.rb', line 90 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.
108 109 110 |
# File 'lib/hanami/configuration.rb', line 108 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
57 58 59 60 61 62 63 |
# File 'lib/hanami/configuration.rb', line 57 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
34 35 36 |
# File 'lib/hanami/configuration.rb', line 34 def mount(app, ) mounted[app] = App.new(app, .fetch(:at)) 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.
96 97 98 |
# File 'lib/hanami/configuration.rb', line 96 def mounted settings.fetch_or_store(:mounted, {}) end |