module SlackScratcher::Helper
SlackScratcher
helper module @since 0.0.1
Public Class Methods
index_data(dataset, column)
click to toggle source
Index data for searching by specific column
@param [Array<Hash>] dataset Dataset @param [String] column column key for indexing
@example Index name column
data = [{name: 'foo', value: 10}, {name: 'bar', value: 20}] indexed_data = helper.index_data(data, :name) indexed_data['foo'][:value] == 10 #=> true
@return [Hash] indexed hash
# File lib/slack_scratcher/helper.rb, line 16 def self.index_data(dataset, column) dataset.map { |data| { data[column] => data } }.inject({}, :merge) end