Skip to content

Instantly share code, notes, and snippets.

Created February 8, 2016 14:30
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 anonymous/3382aa187731aa94eea3 to your computer and use it in GitHub Desktop.
Save anonymous/3382aa187731aa94eea3 to your computer and use it in GitHub Desktop.
module XtSoap
class Config < OpenStruct
class << self
path = File.join('config', 'xt.yml')
config_data = YAML.load(ERB.new(File.read(path)).result)['xt']
config_data.each do |k,v|
define_method(k.to_sym, lambda {__deep_struct__(v)})
end
private
def __deep_struct__(h)
struct = {}
h.each do |k,v|
struct.merge!({k => v.kind_of?(Hash) ? __deep_struct__(v) : v})
end
new(struct)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment