-
-
Save anonymous/3382aa187731aa94eea3 to your computer and use it in GitHub Desktop.
This file contains 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
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