module Padrino::Configuration

Padrino simple configuration module

Public Instance Methods

config() click to toggle source

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
# File lib/padrino-core/configuration.rb, line 17
def config
  @config ||= OpenStruct.new
end
configure(*environments) { |config| ... } click to toggle source

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
# File lib/padrino-core/configuration.rb, line 36
def configure(*environments)
  yield(config) if environments.empty? || environments.include?(Padrino.env)
end