Class: Hanami::EnvironmentApplicationConfigurations

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/environment_application_configurations.rb

Constant Summary collapse

ALL =
:all

Instance Method Summary collapse

Constructor Details

#initializeEnvironmentApplicationConfigurations

Returns a new instance of EnvironmentApplicationConfigurations


5
6
7
# File 'lib/hanami/environment_application_configurations.rb', line 5

def initialize
  @configurations = Concurrent::Hash.new { |k, v| k[v] = [] }
end

Instance Method Details

#add(environment, &blk) ⇒ Object


9
10
11
12
# File 'lib/hanami/environment_application_configurations.rb', line 9

def add(environment, &blk)
  env = (environment || ALL).to_sym
  configurations[env].push(blk)
end

#each(environment, &blk) ⇒ Object


14
15
16
17
18
19
# File 'lib/hanami/environment_application_configurations.rb', line 14

def each(environment, &blk)
  configurations.each do |env, blks|
    next unless matching_env?(environment, env)
    blks.each(&blk)
  end
end