Class: Listen::Change

Inherits:
Object
  • Object
show all
Includes:
Celluloid
Defined in:
lib/listen/change.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(listener) ⇒ Change

Returns a new instance of Change.



10
11
12
# File 'lib/listen/change.rb', line 10

def initialize(listener)
  @listener = listener
end

Instance Attribute Details

#listenerObject

Returns the value of attribute listener.



8
9
10
# File 'lib/listen/change.rb', line 8

def listener
  @listener
end

Instance Method Details

#_dir_change(path, options) ⇒ Object (private)



32
33
34
# File 'lib/listen/change.rb', line 32

def _dir_change(path, options)
  Directory.new(path, options).scan
end

#_file_change(path, options) ⇒ Object (private)



25
26
27
28
29
30
# File 'lib/listen/change.rb', line 25

def _file_change(path, options)
  change = File.new(path).change
  if change && listener.listen? && !options[:silence]
    _notify_listener(change, path)
  end
end

#_notify_listener(change, path) ⇒ Object (private)



36
37
38
# File 'lib/listen/change.rb', line 36

def _notify_listener(change, path)
  listener.changes << { change => path }
end

#_silencerObject (private)



40
41
42
# File 'lib/listen/change.rb', line 40

def _silencer
  Celluloid::Actor[:listen_silencer]
end

#change(path, options) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/listen/change.rb', line 14

def change(path, options)
  return if _silencer.silenced?(path)
  if change = options[:change]
    _notify_listener(change, path)
  else
    send("_#{options[:type].downcase}_change", path, options)
  end
end