Class: Pistol

Inherits:
Object
  • Object
show all
Defined in:
lib/pistol.rb

Constant Summary collapse

VERSION =
"0.0.2"

Instance Method Summary collapse

Constructor Details

#initialize(app, files, &block) ⇒ Pistol

Returns a new instance of Pistol.



4
5
6
7
8
9
# File 'lib/pistol.rb', line 4

def initialize(app, files, &block)
  @app   = app
  @files = files.map { |file| File.expand_path(file) }
  @block = block
  @last  = last_mtime
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pistol.rb', line 11

def call(env)
  current = last_mtime

  if current > @last
    if Thread.list.size > 1
      Thread.exclusive { reload! }
    else
      reload!
    end

    @last = current
  end

  @app.call(env)
end