Class: Hanami::Configuration Private
- Inherits:
-
Object
- Object
- Hanami::Configuration
- Defined in:
- lib/hanami/configuration.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
Instance Method Summary collapse
- #apps ⇒ Object private
-
#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
-
#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.
23 24 25 26 |
# File 'lib/hanami/configuration.rb', line 23 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.
112 113 114 115 116 |
# File 'lib/hanami/configuration.rb', line 112 def apps mounted.each_pair do |klass, app| yield(app) if klass.ancestors.include?(Hanami::Application) 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
176 177 178 |
# File 'lib/hanami/configuration.rb', line 176 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
148 149 150 151 152 153 154 |
# File 'lib/hanami/configuration.rb', line 148 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
94 95 96 |
# File 'lib/hanami/configuration.rb', line 94 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.
100 101 102 |
# File 'lib/hanami/configuration.rb', line 100 def mailer_settings settings.fetch_or_store(:mailers, []) 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
67 68 69 70 71 72 73 |
# File 'lib/hanami/configuration.rb', line 67 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
44 45 46 |
# File 'lib/hanami/configuration.rb', line 44 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.
106 107 108 |
# File 'lib/hanami/configuration.rb', line 106 def mounted settings.fetch_or_store(:mounted, {}) end |