Sha256: 8199e9a0befda42ed9e19c5fb3f93e5b9a677883ccd079bc6310441e22677e2f

Contents?: true

Size: 605 Bytes

Versions: 2

Compression:

Stored size: 605 Bytes

Contents

module Satisfactory
  # Finds the upstream record of a given type.
  #
  # @api private
  class UpstreamRecordFinder
    def initialize(upstream:)
      @upstream = upstream
    end

    attr_accessor :upstream

    def find(type)
      raise MissingUpstreamRecordError, type if upstream.nil?

      if type == upstream.type
        self
      else
        self.upstream = upstream.upstream
        find(type)
      end
    end

    def with(*args, **kwargs)
      upstream.with(*args, force: true, **kwargs)
    end

    # @api private
    class MissingUpstreamRecordError < StandardError; end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
satisfactory-0.2.1 lib/satisfactory/upstream_record_finder.rb
satisfactory-0.2.0 lib/satisfactory/upstream_record_finder.rb