Skip to content

Instantly share code, notes, and snippets.

@jasonkarns
Created March 8, 2016 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonkarns/19b543393a67d85196f9 to your computer and use it in GitHub Desktop.
Save jasonkarns/19b543393a67d85196f9 to your computer and use it in GitHub Desktop.
Deserialize YAML config file into a singleton instance
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