class TFSGraph::Normalizer
Public Class Methods
normalize(item)
click to toggle source
# File lib/tfs_graph/normalizer.rb, line 8 def normalize(item) representation = {} schema.each do |key, lookup| if lookup[:key].present? # for keys that pull data from other sources value = item.send lookup[:key] value = lookup[:converter].call(value) if lookup[:converter].present? else value = lookup[:default] end representation[key] = value end representation end
normalize_many(data)
click to toggle source
# File lib/tfs_graph/normalizer.rb, line 4 def normalize_many(data) data.map {|item| normalize item } end
Private Class Methods
schema()
click to toggle source
# File lib/tfs_graph/normalizer.rb, line 25 def schema raise NoMethodError, "please define the schema in the Normalizer subclass" end