Module: Konfigurator::Common::ClassMethods

Defined in:
lib/konfigurator.rb

Overview

InstanceMethods

Instance Method Summary collapse

Instance Method Details

#configure(*envs, &block) ⇒ Object

Run once, at startup, in any environment. To add an option use the set method (For boolean values You can use #enable and #disable methods):

configure do
  set :foo, 'bar'
  enable :bar
  disable :yadayada
end

Run only when the environment (or the APP_ENV env variable)is set to :production:

configure :production do
  ...
end

Run when the environment is set to either :production or :test:

configure :production, :test do
  ...
end


46
47
48
# File 'lib/konfigurator.rb', line 46

def configure(*envs, &block)
  class_eval(&block) if envs.empty? || envs.include?(env.to_sym)   
end

#environmentObject Also known as: env

It returns name of current environment.



57
58
59
# File 'lib/konfigurator.rb', line 57

def environment
  settings[:environment] ||= settings[:env] || ENV["APP_ENV"] || :development
end

#settingsObject Also known as: config

Returns hash with defined configuration options.



51
52
53
# File 'lib/konfigurator.rb', line 51

def settings
  @settings ||= {}
end