Sha256: 0b35a32b9b2b41d68de1f90b9bd4c961ddec07071be4e623260f349d2d0b4da8

Contents?: true

Size: 1.05 KB

Versions: 9

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module Quilt
  module Performance
    class Report
      attr_accessor :events
      attr_accessor :navigations
      attr_accessor :connection

      def self.from_params(params)
        params.transform_keys! { |key| key.underscore.to_sym }
        params[:connection] = { effectiveType: 'unknown' } if params[:connection].blank?

        connection = Connection.from_params(params[:connection])

        Report.new(
          connection: connection,
          navigations: (params[:navigations] || []).map do |navigation|
            navigation = Navigation.from_params(navigation)
            navigation.connection = connection
            navigation
          end,
          events: (params[:events] || []).map do |event|
            event = Event.from_params(event)
            event.connection = connection
            event
          end,
        )
      end

      def initialize(events:, navigations:, connection:)
        @events = events
        @navigations = navigations
        @connection = connection
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
quilt_rails-3.3.0 lib/quilt_rails/performance/report.rb
quilt_rails-3.2.1 lib/quilt_rails/performance/report.rb
quilt_rails-3.1.1 lib/quilt_rails/performance/report.rb
quilt_rails-3.1.0 lib/quilt_rails/performance/report.rb
quilt_rails-3.0.0 lib/quilt_rails/performance/report.rb
quilt_rails-2.0.0 lib/quilt_rails/performance/report.rb
quilt_rails-1.13.0 lib/quilt_rails/performance/report.rb
quilt_rails-1.12.2 lib/quilt_rails/performance/report.rb
quilt_rails-1.12.1 lib/quilt_rails/performance/report.rb