display/config/initializers/misc.rb
def to_map_with_value(&block)
    inject({}) do |h, e|
      key, value = yield(e)
      h[key] = value
      h
    end
  end
# Quick convenient way to convert array of objects to hash of key/value pair determined by passed-in block.
#   x = %w(a bb ccc)
#   x.to_hash_with_value {|e| return e, e.size}    #  {"a" +> 1, "bb" => 2, "ddd" => 3}
Quick convenient way to convert array of objects to hash of key/value pair determined by passed-in block.
Quick convenient way to convert array of objects to hash of key / value pair determined by passed - in block .
def to_map_with_value(&block)
    inject({}) do |h, e|
      key, value = yield(e)
      h[key] = value
      h
    end
  end
def to_map_with_value ( & block ) inject ( { } ) do | h , e | key , value = yield ( e ) h [ key ] = value h end end
Quick convenient way to convert array of objects to hash of key/value pair determined by passed-in block.
Quick convenient way to convert array of objects to hash of key / value pair determined by passed - in block .
block