Module: Hanami::Application::ClassMethods
- Defined in:
- lib/hanami/application.rb
Overview
Class interface for Hanami applications
Class Method Summary collapse
-
.extended(base) ⇒ Object
private
Override Ruby’s Class#extended.
Instance Method Summary collapse
-
#app_name ⇒ String
private
Hanami application name.
-
#configuration=(configuration) ⇒ Object
private
Set configuration.
-
#configure(environment = nil, &blk) ⇒ Object
Configure the application.
Class Method Details
.extended(base) ⇒ 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.
Override Ruby’s Class#extended
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/hanami/application.rb', line 73 def self.extended(base) # rubocop:disable Metrics/MethodLength super base.class_eval do @namespace = ApplicationNamespace.resolve(name) @configurations = EnvironmentApplicationConfigurations.new @_lock = Mutex.new class << self # @since 0.9.0 # @api private attr_reader :namespace # @since 0.9.0 # @api private attr_reader :configurations # @since 0.9.0 # @api private attr_reader :configuration end end end |
Instance Method Details
#app_name ⇒ String
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.
Hanami application name
113 114 115 |
# File 'lib/hanami/application.rb', line 113 def app_name ApplicationName.new(name).to_s end |
#configuration=(configuration) ⇒ 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.
Set configuration
125 126 127 128 129 130 |
# File 'lib/hanami/application.rb', line 125 def configuration=(configuration) @_lock.synchronize do raise "Can't assign configuration more than once (#{app_name})" unless @configuration.nil? @configuration = configuration end end |
#configure(environment = nil, &blk) ⇒ Object
Configure the application. It yields the given block in the context of the configuration
152 153 154 |
# File 'lib/hanami/application.rb', line 152 def configure(environment = nil, &blk) configurations.add(environment, &blk) end |