Sha256: c6b991f5c571055365b9516ad8b0af8305c5db4ab1d3d2eacdfe570ef6d1176c

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

module Bundler
  module Alive
    #
    # Represents Result of Status
    #
    class StatusResult
      attr_reader :collection, :error_messages, :rate_limit_exceeded

      #
      # Creates a new StatusResult instance
      #
      # @param [StatusCollection|nil] :collection
      # @param [Array|nil] :error_messages
      # @param [Boolean|nil] :rate_limit_exceeded
      #
      # @return [StatusResult]
      #
      def initialize(collection: StatusCollection.new, error_messages: [], rate_limit_exceeded: false)
        @collection = collection
        @error_messages = error_messages
        @rate_limit_exceeded = rate_limit_exceeded

        freeze
      end

      #
      # Merge `StatusResult`, then returns new one
      #
      # @param [StatusResult] result
      #
      # @return [StatusResult]
      #
      def merge(result)
        merged_collection = collection.merge(result.collection)
        merged_error_messages = error_messages + result.error_messages
        merged_rate_limit_exceeded = rate_limit_exceeded || result.rate_limit_exceeded
        self.class.new(collection: merged_collection,
                       error_messages: merged_error_messages,
                       rate_limit_exceeded: merged_rate_limit_exceeded)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bundler-alive-0.1.7 lib/bundler/alive/status_result.rb
bundler-alive-0.1.6 lib/bundler/alive/status_result.rb