lib/elasticonf/config.rb in elasticonf-1.0.0 vs lib/elasticonf/config.rb in elasticonf-1.1.0

- old
+ new

@@ -1,41 +1,49 @@ module ElastiConf - module Config - def configure - yield self - end - + class Config def reset_config! %w( + env config_root config_file const_name raise_if_already_initialized_constant ).each do |v| instance_variable_set "@#{v}", nil end end + + def env + @env ||= 'development' + end + def env=(value) + unless [String, Symbol].include?(value.class) + raise ArgumentError, "String or Symbol expected #{value.class} given" + end + @env = value.to_s + end + def config_root - @config_root ||= raise(ArgumentError, 'You must first specify config root') + @config_root ||= raise(ArgumentError, 'You must specify config_root option first') end def config_root=(value) unless [String, Symbol, Pathname].include?(value.class) - raise ArgumentError, "String or Pathname expected #{value.class} given" + raise ArgumentError, "String or Symbol or Pathname expected #{value.class} given" end - @config_root = value.is_a?(String) ? Pathname.new(value.to_s) : value + @config_root = value.is_a?(Pathname) ? value : Pathname.new(value.to_s) end def config_file @config_file ||= 'config' end def config_file=(value) unless [String, Symbol].include?(value.class) raise ArgumentError, "String or Symbol expected #{value.class} given" end - @config_file = value + @config_file = value.to_s end def const_name @const_name ||= 'Settings' end \ No newline at end of file