-
-
Save mouse-lin/5089859 to your computer and use it in GitHub Desktop.
load yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Settings | |
def self.get key | |
val = data.fetch(Rails.env, nil).try(:[], ENV["PLATFORM"]).try(:[], key) | |
raise "value nil in #{ Rails.en }" if val.nil? && Rails.env != "test" | |
val | |
end | |
def self.data | |
@data ||= YAML.load_file File.join(Rails.root, "config/settings.yml") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment