Class: Rack::FileWatcher
- Inherits:
-
Object
- Object
- Rack::FileWatcher
- Defined in:
- lib/rack/file_watcher.rb,
lib/rack/file_watcher/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Method Summary collapse
- #call(env) ⇒ Object
- #execute_if_updated ⇒ Object
-
#initialize(app, file_path, &block) ⇒ FileWatcher
constructor
A new instance of FileWatcher.
Constructor Details
#initialize(app, file_path, &block) ⇒ FileWatcher
Returns a new instance of FileWatcher.
6 7 8 9 10 11 12 13 14 |
# 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 |
Instance Method Details
#call(env) ⇒ Object
25 26 27 28 29 |
# File 'lib/rack/file_watcher.rb', line 25 def call(env) execute_if_updated @app.call(env) end |
#execute_if_updated ⇒ Object
16 17 18 19 20 21 22 23 |
# 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 |