Class: PGTrunk::DependenciesResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/pg_trunk/core/dependencies_resolver.rb

Overview

Resolve dependencies between inter-dependent objects, identified by database #oid and comparable to each other.

The method builds the sorted list:

  • parent objects moved before their dependants.
  • independent objects keeps their original order.

We have no expectations about the natural order here.

See Also:

  • [PGTrunk[PGTrunk::ObjectDefinitions[PGTrunk::ObjectDefinitions::Operation]

Class Method Summary collapse

Class Method Details

.resolve(objects) ⇒ Array<#oid>

Resolve dependencies between objects

Parameters:

  • objects (Array<Enumerable, #oid>)

    The list of objects

Returns:

  • (Array<#oid>)

    The sorted list of objects

Raises:

  • (Dependencies::CycleError)

    if dependencies contain a cycle



20
21
22
# File 'lib/pg_trunk/core/dependencies_resolver.rb', line 20

def resolve(objects)
  new(objects, dependencies).send(:sorted)
end