vagrant/lib/hobo/config.rb

28 lines
446 B
Ruby
Raw Normal View History

2010-01-22 05:54:23 +00:00
module Hobo
2010-01-22 08:37:50 +00:00
module_function
def config
@@config
end
def config_from_hash!(hash)
@@config = Config.from_hash(hash)
end
2010-01-22 05:54:23 +00:00
2010-01-22 08:37:50 +00:00
class Config
class << self
def from_hash(value)
2010-01-22 05:54:23 +00:00
return value unless value.instance_of?(Hash)
result = value.inject({}) do |acc, pair|
2010-01-22 08:37:50 +00:00
acc[pair.first] = from_hash(pair.last)
2010-01-22 05:54:23 +00:00
acc
end
OpenStruct.new(result)
end
end
end
end