Class: Sequent::Migrations::Planner

Inherits:
Object
  • Object
show all
Defined in:
lib/sequent/migrations/planner.rb

Defined Under Namespace

Classes: Plan

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(versions) ⇒ Planner

Returns a new instance of Planner.



22
23
24
# File 'lib/sequent/migrations/planner.rb', line 22

def initialize(versions)
  @versions = versions
end

Instance Attribute Details

#versionsObject (readonly)

Returns the value of attribute versions.



20
21
22
# File 'lib/sequent/migrations/planner.rb', line 20

def versions
  @versions
end

Instance Method Details

#plan(old, new) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/sequent/migrations/planner.rb', line 26

def plan(old, new)
  migrations = versions.slice(*Range.new(old + 1, new).to_a.map(&:to_s))

  Plan.new(
    migrations.yield_self(&method(:select_projectors)),
    migrations
      .yield_self(&method(:create_migrations))
      .yield_self(&method(:remove_redundant_migrations)),
  )
end