Class: Rage::Reloader

Inherits:
Object
  • Object
show all
Defined in:
lib/rage/middleware/reloader.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Reloader

Returns a new instance of Reloader.



4
5
6
7
8
9
# File 'lib/rage/middleware/reloader.rb', line 4

def initialize(app)
  Iodine.on_state(:on_start) do
    Rage.code_loader.check_updated!
  end
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/rage/middleware/reloader.rb', line 11

def call(env)
  with_reload do
    @app.call(env)
  end
rescue Exception => e
  exception_str = "#{e.class} (#{e.message}):\n#{e.backtrace.join("\n")}"
  puts(exception_str)
  [500, {}, [exception_str]]
end