Created
April 13, 2011 09:10
-
-
Save aisuii/917243 to your computer and use it in GitHub Desktop.
some_module/config.rb
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
require 'singleton' | |
require 'yaml' | |
require 'rubygems' | |
require 'active_support/core_ext' | |
module SomeModule | |
module Config | |
def self.included(klass) | |
klass.extend ClassMethods | |
end | |
module ClassMethods | |
def config | |
@config ||= Configuration.instance.config | |
end | |
end | |
class Configuration | |
include Singleton | |
attr_reader :config | |
def initialize(yml = 'config.yml') | |
@config = HashWithIndifferentAccess.new(YAML.load(File.read(yml))) | |
@config.freeze | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment