Module: Konfigurator::DSL::ClassMethods
- Defined in:
- lib/konfigurator/dsl.rb
Instance Method Summary collapse
-
#attr_config(*attrs) ⇒ Object
(also: #attr_setting)
It defines given configuration attributes.
-
#environment(env = nil) ⇒ Object
(also: #env)
See Konfigurator#environment for more info.
-
#load_settings(fname) ⇒ Object
See Konfigurator::Simple#load_settings for more info.
Instance Method Details
#attr_config(*attrs) ⇒ Object Also known as: attr_setting
It defines given configuration attributes.
attr_config :host, :port
attr_config :password
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/konfigurator/dsl.rb', line 48 def attr_config(*attrs) attrs.each do |attr| self.class.class_eval <<-EVAL def #{attr.to_s}(value=nil) settings[#{attr.to_sym.inspect}] = value unless value.nil? return settings[#{attr.to_sym.inspect}] end EVAL end end |
#environment(env = nil) ⇒ Object Also known as: env
See Konfigurator#environment for more info.
61 62 63 64 |
# File 'lib/konfigurator/dsl.rb', line 61 def environment(env=nil) settings[:environment] = env unless env.nil? settings[:environment] ||= settings[:env] || ENV["APP_ENV"] || :development end |
#load_settings(fname) ⇒ Object
See Konfigurator::Simple#load_settings for more info.
68 69 70 71 |
# File 'lib/konfigurator/dsl.rb', line 68 def load_settings(fname) conf = YAML.load_file(fname) conf[env.to_s].each {|k,v| send(k.to_sym, v) } end |