class RailsPerformance::Models::Collection
Attributes
data[R]
Public Class Methods
new()
click to toggle source
# File lib/rails_performance/models/collection.rb, line 6 def initialize @data = [] end
Public Instance Methods
add(record)
click to toggle source
# File lib/rails_performance/models/collection.rb, line 10 def add(record) @data << record end
fetch_values(groupped_collection)
click to toggle source
# File lib/rails_performance/models/collection.rb, line 23 def fetch_values(groupped_collection) result = {} groupped_collection.each do |key, records| result[key] ||= [] records.each do |record| result[key] << record.value end end result end
group_by(type)
click to toggle source
# File lib/rails_performance/models/collection.rb, line 14 def group_by(type) case type when :controller_action, :controller_action_format, :datetime, :path fetch_values @data.group_by(&type) else {} end end