Module: Bizside::Configurations::Storage

Included in:
Bizside::Config
Defined in:
lib/bizside/configurations/storage.rb

Instance Method Summary collapse

Instance Method Details

#storageObject



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/bizside/configurations/storage.rb', line 5

def storage
  return @storage if defined? @storage

  configfile = ENV['STORAGE_CONFIG_FILE'] ? ENV['STORAGE_CONFIG_FILE'] : default_configfile
  @storage = if File.exist?(configfile)
      text = ERB.new(File.read(configfile), 0, '-').result
      entire_config = YAML.respond_to?(:safe_load) ? YAML.safe_load(text, aliases: true) : YAML.load(text)
      Bizside::Config.new(entire_config[Bizside.env])
    else
      Bizside::Config.new
    end
end