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)
33 34 35 |
# File 'lib/listen/change.rb', line 33 def _dir_change(path, ) Directory.new(listener, path, ).scan end |
#_file_change(path, options) ⇒ Object (private)
26 27 28 29 30 31 |
# File 'lib/listen/change.rb', line 26 def _file_change(path, ) change = File.new(listener, path).change if change && listener.listen? && ![:silence] _notify_listener(change, path) end end |
#_notify_listener(change, path) ⇒ Object (private)
37 38 39 |
# File 'lib/listen/change.rb', line 37 def _notify_listener(change, path) listener.changes << { change => path } end |
#_silencer ⇒ Object (private)
41 42 43 |
# File 'lib/listen/change.rb', line 41 def _silencer listener.registry[:silencer] end |
#change(path, options) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/listen/change.rb', line 14 def change(path, ) return if _silencer.silenced?(path, [:type]) if change = [:change] _notify_listener(change, path) else send("_#{[:type].downcase}_change", path, ) end end |