Class: ActiveGraph::Migrations::CheckPending

Inherits:
Object
  • Object
show all
Defined in:
lib/active_graph/migrations/check_pending.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ CheckPending

Returns a new instance of CheckPending.


4
5
6
7
# File 'lib/active_graph/migrations/check_pending.rb', line 4

def initialize(app)
  @app = app
  @last_check = 0
end

Instance Method Details

#call(env) ⇒ Object


9
10
11
12
13
14
15
16
17
# File 'lib/active_graph/migrations/check_pending.rb', line 9

def call(env)
  latest_migration = ActiveGraph::Migrations::Runner.latest_migration
  mtime = latest_migration ? latest_migration.version.to_i : 0
  if @last_check < mtime
    ActiveGraph::Migrations.check_for_pending_migrations!
    @last_check = mtime
  end
  @app.call(env)
end