Module: Ken::Util

Defined in:
lib/ken/util.rb

Instance Method Summary collapse

Instance Method Details

#convert_hash(source) ⇒ Object

magic hash conversion



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/ken/util.rb', line 4

def convert_hash(source)
  source.inject({}) do |result, item|
    if result[item["link"]]
      result[item["link"]] << { "id" => item["id"], "name" => item["name"], "value" => item["value"] }
    else
      result[item["link"]] = []
      result[item["link"]] << { "id" => item["id"], "name" => item["name"], "value" => item["value"] }
    end
    result
  end
end