Module: Konfigurator::Common::ClassMethods
- Defined in:
- lib/konfigurator.rb
Overview
InstanceMethods
Instance Method Summary collapse
-
#configure(*envs, &block) ⇒ Object
Run once, at startup, in any environment.
-
#environment ⇒ Object
(also: #env)
It returns name of current environment.
-
#settings ⇒ Object
Returns hash with defined configuration options.
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 |
#environment ⇒ Object Also known as: env
It returns name of current environment.
56 57 58 |
# File 'lib/konfigurator.rb', line 56 def environment settings[:environment] ||= settings[:env] || ENV["RAILS_ENV"] || ENV["APP_ENV"] || :development end |
#settings ⇒ Object
Returns hash with defined configuration options.
51 52 53 |
# File 'lib/konfigurator.rb', line 51 def settings @settings ||= {} end |