Sha256: 366b6c19ac1f380a123db3e1e760bfd2584b81a7c20da93cdbd81a647c3f5d42

Contents?: true

Size: 731 Bytes

Versions: 49

Compression:

Stored size: 731 Bytes

Contents

module RailsPerformance
  module Models
    class Collection
      attr_reader :data

      def initialize
        @data = []
      end

      def add(record)
        @data << record
      end

      def group_by(type)
        case type
        when :controller_action, :controller_action_format, :datetime, :path
          fetch_values @data.group_by(&type)
        else
          {}
        end
      end

      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

    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
rails_performance-1.2.3 lib/rails_performance/models/collection.rb
rails_performance-1.2.2 lib/rails_performance/models/collection.rb
rails_performance-1.2.1 lib/rails_performance/models/collection.rb
rails_performance-1.2.0 lib/rails_performance/models/collection.rb
rails_performance-1.2.0.alpha5 lib/rails_performance/models/collection.rb
rails_performance-1.2.0.alpha4 lib/rails_performance/models/collection.rb
rails_performance-1.2.0.alpha3 lib/rails_performance/models/collection.rb
rails_performance-1.2.0.alpha2 lib/rails_performance/models/collection.rb
rails_performance-1.2.0.alpha1 lib/rails_performance/models/collection.rb
rails_performance-1.1.0 lib/rails_performance/models/collection.rb
rails_performance-1.0.5.3 lib/rails_performance/models/collection.rb
rails_performance-1.0.5.2 lib/rails_performance/models/collection.rb
rails_performance-1.0.5.1 lib/rails_performance/models/collection.rb
rails_performance-1.0.5 lib/rails_performance/models/collection.rb
rails_performance-1.0.4 lib/rails_performance/models/collection.rb
rails_performance-1.0.3 lib/rails_performance/models/collection.rb
rails_performance-1.0.2 lib/rails_performance/models/collection.rb
rails_performance-1.0.1 lib/rails_performance/models/collection.rb
rails_performance-1.0.0 lib/rails_performance/models/collection.rb
rails_performance-1.0.0.beta5 lib/rails_performance/models/collection.rb