Sha256: 0f7640c9727d30261548e38b4715946331ffc4e303cf20f06594ec8dc1479861

Contents?: true

Size: 1 KB

Versions: 26

Compression:

Stored size: 1 KB

Contents

require 'ostruct'

module Padrino
  ##
  # Padrino simple configuration module
  #
  module Configuration
    ##
    # Returns the configuration structure allowing to get and set it's values.
    # Padrino.config is a simple Ruby OpenStruct object with no additional magic.
    #
    # Example:
    #
    #   Padrino.config.value1 = 42
    #   exit if Padrino.config.exiting
    #
    def config
      @config ||= OpenStruct.new
    end

    ##
    # Allows to configure different environments differently. Requires a block.
    #
    # Example:
    #
    #   Padrino.configure :development do |config|
    #     config.value2 = 'only development'
    #   end
    #   Padrino.configure :development, :production do |config|
    #     config.value2 = 'both development and production'
    #   end
    #   Padrino.configure do |config|
    #     config.value2 = 'any environment'
    #   end
    #
    def configure(*environments)
      yield(config) if environments.empty? || environments.include?(Padrino.env)
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
padrino-core-0.16.0.pre3 lib/padrino-core/configuration.rb
padrino-core-0.16.0.pre2 lib/padrino-core/configuration.rb
padrino-core-0.15.3 lib/padrino-core/configuration.rb
padrino-core-0.15.2 lib/padrino-core/configuration.rb
padrino-core-0.15.1 lib/padrino-core/configuration.rb
padrino-core-0.15.0 lib/padrino-core/configuration.rb
padrino-core-0.14.4 lib/padrino-core/configuration.rb
padrino-core-0.14.3 lib/padrino-core/configuration.rb
padrino-core-0.12.9 lib/padrino-core/configuration.rb
padrino-core-0.14.2 lib/padrino-core/configuration.rb
padrino-core-0.13.3.4 lib/padrino-core/configuration.rb
padrino-core-0.14.1.1 lib/padrino-core/configuration.rb
padrino-core-0.14.1 lib/padrino-core/configuration.rb
padrino-core-0.14.0.2 lib/padrino-core/configuration.rb
padrino-core-0.14.0.1 lib/padrino-core/configuration.rb
padrino-core-0.14.0 lib/padrino-core/configuration.rb
padrino-core-0.14.0.rc2 lib/padrino-core/configuration.rb
padrino-core-0.14.0.rc1 lib/padrino-core/configuration.rb
padrino-core-0.13.3.3 lib/padrino-core/configuration.rb
padrino-core-0.13.3.2 lib/padrino-core/configuration.rb