class Rack::FileWatcher
Constants
- VERSION
Public Class Methods
new(app, file_path, &block)
click to toggle source
# File lib/rack/file_watcher.rb, line 6 def initialize(app, file_path, &block) @app = app @file_path = file_path @block = block initialize_target_file @last_update_at = updated_at end
Public Instance Methods
call(env)
click to toggle source
# File lib/rack/file_watcher.rb, line 25 def call(env) execute_if_updated @app.call(env) end
execute_if_updated()
click to toggle source
# File lib/rack/file_watcher.rb, line 16 def execute_if_updated current_updated_at = updated_at if @last_update_at != current_updated_at @block.call @last_update_at = current_updated_at end end
Private Instance Methods
initialize_target_file()
click to toggle source
# File lib/rack/file_watcher.rb, line 33 def initialize_target_file FileUtils.touch(@file_path) end
updated_at()
click to toggle source
# File lib/rack/file_watcher.rb, line 37 def updated_at ::File.mtime(@file_path) end