class HierarchicalConfig::OpenStruct

Public Instance Methods

[](attribute) click to toggle source
# File lib/hierarchical_config.rb, line 33
def [](attribute)
  send(attribute)
end
to_hash() click to toggle source
# File lib/hierarchical_config.rb, line 39
def to_hash
  @table.inject({}) do |hash, key_value|
    key, value = *key_value
    hash[key] = item_to_hash(value)
    hash
  end
end

Private Instance Methods

item_to_hash(value) click to toggle source
# File lib/hierarchical_config.rb, line 49
def item_to_hash(value)
  case value
  when Array
    value.map{|item| item_to_hash(item)}
  when OpenStruct
    value.to_hash
  else
    value
  end
end