Class: Observr::EventHandler::Unix::SingleFileWatcher
- Inherits:
-
Rev::StatWatcher
- Object
- Rev::StatWatcher
- Observr::EventHandler::Unix::SingleFileWatcher
- Defined in:
- lib/observr/event_handlers/unix.rb
Overview
Used by Rev. Wraps a monitored path, and ‘Rev::Loop` will call its callback on file events.
Class Attribute Summary collapse
-
.handler ⇒ EventHandler::Base
Stores a reference back to handler so we can call its notify method with file event info.
Instance Method Summary collapse
-
#initialize(path) ⇒ SingleFileWatcher
constructor
A new instance of SingleFileWatcher.
-
#on_change ⇒ undefined
Callback.
-
#pathname ⇒ Pathname
File’s path as a Pathname.
Constructor Details
#initialize(path) ⇒ SingleFileWatcher
Returns a new instance of SingleFileWatcher.
23 24 25 26 |
# File 'lib/observr/event_handlers/unix.rb', line 23 def initialize(path) super update_reference_times end |
Class Attribute Details
.handler ⇒ EventHandler::Base
Stores a reference back to handler so we can call its notify method with file event info
17 18 19 |
# File 'lib/observr/event_handlers/unix.rb', line 17 def handler @handler end |
Instance Method Details
#on_change ⇒ undefined
Callback. Called on file change event. Delegates to Controller#update, passing in path and event type
41 42 43 44 |
# File 'lib/observr/event_handlers/unix.rb', line 41 def on_change self.class.handler.notify(path, type) update_reference_times unless type == :deleted end |
#pathname ⇒ Pathname
File’s path as a Pathname
32 33 34 |
# File 'lib/observr/event_handlers/unix.rb', line 32 def pathname @pathname ||= Pathname(@path) end |