Class: Wake::EventHandler::Rev::SingleFileWatcher

Inherits:
Rev::StatWatcher
  • Object
show all
Defined in:
lib/wake/event_handlers/rev.rb

Overview

Used by Rev. Wraps a monitored path, and Rev::Loop will call its callback on file events.

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ SingleFileWatcher

Returns a new instance of SingleFileWatcher.



22
23
24
25
# File 'lib/wake/event_handlers/rev.rb', line 22

def initialize(path)
  super
  update_reference_times
end

Class Attribute Details

.handlerObject

Stores a reference back to handler so we can call its #nofity method with file event info



19
20
21
# File 'lib/wake/event_handlers/rev.rb', line 19

def handler
  @handler
end

Instance Method Details

#on_changeObject

Callback. Called on file change event Delegates to Controller#update, passing in path and event type



34
35
36
37
# File 'lib/wake/event_handlers/rev.rb', line 34

def on_change
  self.class.handler.notify(path, type)
  update_reference_times unless type == :deleted
end

#pathnameObject

File’s path as a Pathname



28
29
30
# File 'lib/wake/event_handlers/rev.rb', line 28

def pathname
  @pathname ||= Pathname(@path)
end