Created
March 8, 2016 00:43
-
-
Save jasonkarns/19b543393a67d85196f9 to your computer and use it in GitHub Desktop.
Deserialize YAML config file into a singleton instance
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' | |
class Configuration | |
include Singleton | |
def init_with(attributes) | |
attributes.map.each do |k,v| | |
self.class.instance.instance_variable_set(:"@#{k}", v) | |
end | |
end | |
public_class_method :allocate | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment