Class: Listen::Change
- Inherits:
-
Object
- Object
- Listen::Change
- Includes:
- Celluloid
- Defined in:
- lib/listen/change.rb
Instance Attribute Summary collapse
-
#listener ⇒ Object
Returns the value of attribute listener.
Instance Method Summary collapse
- #_dir_change(path, options) ⇒ Object private
- #_file_change(path, options) ⇒ Object private
- #_notify_listener(change, path) ⇒ Object private
- #_silencer ⇒ Object private
- #change(path, options) ⇒ Object
-
#initialize(listener) ⇒ Change
constructor
A new instance of Change.
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
#listener ⇒ Object
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, ) Directory.new(path, ).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, ) change = File.new(path).change if change && listener.listen? && ![: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 |
#_silencer ⇒ Object (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, ) return if _silencer.silenced?(path) if change = [:change] _notify_listener(change, path) else send("_#{[:type].downcase}_change", path, ) end end |