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.



24
25
26
# File 'lib/sequent/migrations/planner.rb', line 24

def initialize(versions)
  @versions = versions
end

Instance Attribute Details

#versionsObject (readonly)

Returns the value of attribute versions.



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

def versions
  @versions
end

Instance Method Details

#plan(old, new) ⇒ Object



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

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