Skip to content

Instantly share code, notes, and snippets.

@ysv
Last active September 9, 2019 09:50
Show Gist options
  • Save ysv/1cc39a7a8f22a55821e3604296d4b861 to your computer and use it in GitHub Desktop.
Save ysv/1cc39a7a8f22a55821e3604296d4b861 to your computer and use it in GitHub Desktop.
module MyApp
def config
Config.instance
end
class Config
include Singleton
attr_reader :env
def initialize
yml = YAML.load_file("config.yml")
@env = ENV.fetch('MY_APP_ENV', :development)
@config = Hashie::Mash.new(yml[@env])
end
def method_missing(name, *args, &block)
# if there is no method delegate to @config Mash.
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment