Class: Observr::EventHandler::Unix::SingleFileWatcher

Inherits:
Rev::StatWatcher
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ SingleFileWatcher

Returns a new instance of SingleFileWatcher.

Parameters:

  • path (String)

    single file to monitor



23
24
25
26
# File 'lib/observr/event_handlers/unix.rb', line 23

def initialize(path)
  super
  update_reference_times
end

Class Attribute Details

.handlerEventHandler::Base

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

Returns:



17
18
19
# File 'lib/observr/event_handlers/unix.rb', line 17

def handler
  @handler
end

Instance Method Details

#on_changeundefined

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

Returns:

  • (undefined)


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

#pathnamePathname

File’s path as a Pathname

Returns:

  • (Pathname)


32
33
34
# File 'lib/observr/event_handlers/unix.rb', line 32

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