Class: ActiveSupport::FileWatcher
- Inherits:
-
Object
- Object
- ActiveSupport::FileWatcher
- Defined in:
- activesupport/lib/active_support/file_watcher.rb
Defined Under Namespace
Classes: Backend
Instance Method Summary (collapse)
-
- (FileWatcher) initialize
constructor
A new instance of FileWatcher.
- - (Object) trigger(files)
- - (Object) watch(pattern, &block)
Constructor Details
- (FileWatcher) initialize
A new instance of FileWatcher
14 15 16 |
# File 'activesupport/lib/active_support/file_watcher.rb', line 14 def initialize @regex_matchers = {} end |
Instance Method Details
- (Object) trigger(files)
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'activesupport/lib/active_support/file_watcher.rb', line 22 def trigger(files) trigger_files = Hash.new { |h,k| h[k] = Hash.new { |h2,k2| h2[k2] = [] } } files.each do |file, state| @regex_matchers.each do |pattern, block| trigger_files[block][state] << file if pattern === file end end trigger_files.each do |block, payload| block.call payload end end |
- (Object) watch(pattern, &block)
18 19 20 |
# File 'activesupport/lib/active_support/file_watcher.rb', line 18 def watch(pattern, &block) @regex_matchers[pattern] = block end |