Sha256: 13682fc76ad05630ea02fcbb441fe75e893b5c54acdbf0e5824de23b459ce49d
Contents?: true
Size: 897 Bytes
Versions: 7
Compression:
Stored size: 897 Bytes
Contents
require 'yaml' module Baurets module Optionsful class Configurator DEFAULT = { :link => false, :host => 'auto', :base_path => "/api", :propagate => true } def configure! file = File.join(Rails.root, 'config', 'optionsful.yml') configuration = load_yaml(file, Rails.env.to_sym) if File.exist?(file) configuration = DEFAULT if configuration.nil? configuration end private def load_yaml(file, environment) configuration = nil begin envs = YAML::load_file(file) raise "Could not parse the YAML." if (envs.empty? or (not envs.kind_of?(Hash))) envs = envs.symbolize_keys if envs configuration = envs[environment].symbolize_keys if (envs && envs[environment]) rescue configuration = nil end configuration end end end end
Version data entries
7 entries across 7 versions & 1 rubygems