Class: Satisfactory::UpstreamRecordFinder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/satisfactory/upstream_record_finder.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Finds the upstream record of a given type.

Since:

  • 0.2.0

Defined Under Namespace

Classes: MissingUpstreamRecordError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(upstream:) ⇒ UpstreamRecordFinder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of UpstreamRecordFinder.

Since:

  • 0.2.0



6
7
8
# File 'lib/satisfactory/upstream_record_finder.rb', line 6

def initialize(upstream:)
  @upstream = upstream
end

Instance Attribute Details

#upstreamObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.2.0



11
12
13
# File 'lib/satisfactory/upstream_record_finder.rb', line 11

def upstream
  @upstream
end

Instance Method Details

#createHash<Symbol, Array<ApplicationRecord>>

Delegates to the upstream record.

Returns:

  • (Hash<Symbol, Array<ApplicationRecord>>)

See Also:



25
# File 'lib/satisfactory/upstream_record_finder.rb', line 25

delegate :create, :with_new, :to_plan, to: :upstream

#find(type) ⇒ Satisfactory::Record, ...

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Find the upstream record of the given type.

Parameters:

  • type (Symbol)

    The type of upstream record to find.

Returns:

Raises:

Since:

  • 0.2.0



32
33
34
35
36
37
38
39
40
41
# File 'lib/satisfactory/upstream_record_finder.rb', line 32

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

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

#to_planSatisfactory::Record, Satisfactory::Collection

Delegates to the upstream record.



25
# File 'lib/satisfactory/upstream_record_finder.rb', line 25

delegate :create, :with_new, :to_plan, to: :upstream

#with(*args, **kwargs) ⇒ Satisfactory::Record, Satisfactory::Collection

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Add an associated record to this record’s build plan.

Parameters:

  • count (Integer)

    The number of records to create.

  • downstream_type (Symbol)

    The type of record to create.

  • force (Boolean)

    Whether to force the creation of the record. For internal use only. Use #and instead.

  • attributes (Hash)

    The attributes to use when creating the record.

Returns:

Since:

  • 0.2.0



44
45
46
# File 'lib/satisfactory/upstream_record_finder.rb', line 44

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

#with_newSatisfactory::Record, Satisfactory::Collection

Delegates to the upstream record.



25
# File 'lib/satisfactory/upstream_record_finder.rb', line 25

delegate :create, :with_new, :to_plan, to: :upstream