Module: EnvironmentConfigurable::ClassMethods

Defined in:
lib/environment_configurable.rb

Instance Method Summary collapse

Instance Method Details

#configObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/environment_configurable.rb', line 16

def config
  unless @config_wrappers
    @config_data = YAML.load(ERB.new(File.read(@configured_with_file)).result)
    @config_wrappers = {}
    @config_data.each do |env_name, hash|
      @config_wrappers[env_name] = ConfigWrapper.new(hash)
    end
  end
  @config_wrappers[Rails.env]
end

#configure_with(file) ⇒ Object



9
10
11
12
13
14
# File 'lib/environment_configurable.rb', line 9

def configure_with(file)
  @configured_with_file = "#{Rails.root}/#{file}"
  unless File.exist?(@configured_with_file)
    raise "Can't configure class #{self.name} -- no file #{@configured_with_file}"
  end
end