Sha256: 275f20ab258c1fd3d730adaff65ba759ce3cd33a3710c6d6fe89ed9074227712

Contents?: true

Size: 742 Bytes

Versions: 21

Compression:

Stored size: 742 Bytes

Contents

module Hanami
  # @api private
  class EnvironmentApplicationConfigurations
    # @api private
    ALL = :all

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

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

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

    private

    # @api private
    attr_reader :configurations

    # @api private
    def matching_env?(environment, env)
      environment.to_sym == env ||
        env == ALL
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
hanami-1.3.5 lib/hanami/environment_application_configurations.rb
hanami-1.3.4 lib/hanami/environment_application_configurations.rb
hanami-1.3.3 lib/hanami/environment_application_configurations.rb
hanami-1.3.2 lib/hanami/environment_application_configurations.rb
hanami-1.3.1 lib/hanami/environment_application_configurations.rb
hanami-1.3.0 lib/hanami/environment_application_configurations.rb
hanami-1.3.0.beta1 lib/hanami/environment_application_configurations.rb
hanami-1.2.0 lib/hanami/environment_application_configurations.rb
hanami-1.2.0.rc2 lib/hanami/environment_application_configurations.rb
hanami-1.2.0.rc1 lib/hanami/environment_application_configurations.rb
hanami-1.2.0.beta2 lib/hanami/environment_application_configurations.rb
hanami-1.2.0.beta1 lib/hanami/environment_application_configurations.rb
hanami-1.1.1 lib/hanami/environment_application_configurations.rb
hanami-1.1.0 lib/hanami/environment_application_configurations.rb
hanami-1.1.0.rc1 lib/hanami/environment_application_configurations.rb
hanami-1.1.0.beta3 lib/hanami/environment_application_configurations.rb
hanami-1.1.0.beta2 lib/hanami/environment_application_configurations.rb
hanami-1.1.0.beta1 lib/hanami/environment_application_configurations.rb
hanami-1.0.0 lib/hanami/environment_application_configurations.rb
hanami-1.0.0.rc1 lib/hanami/environment_application_configurations.rb