Class: Neo4j::Migrations::CheckPending

Inherits:
Object
  • Object
show all
Defined in:
lib/neo4j/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/neo4j/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/neo4j/migrations/check_pending.rb', line 9

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