Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemanrubia committed Dec 15, 2024
1 parent 95bd924 commit e3fa36e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/hotwire_spark/file_watcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

class HotwireSpark::FileWatcher
def initialize
@blocks_by_path = Hash.new { |hash, key| hash[key] = [] }
@callbacks_by_path = Hash.new { |hash, key| hash[key] = [] }
end

def monitor(paths, &block)
def monitor(paths, &callback)
Array(paths).each do |path|
@blocks_by_path[expand_path(path)] << block
@callbacks_by_path[expand_path(path)] << callback
end
end

Expand All @@ -25,14 +25,14 @@ def expand_path(path)
end

def paths
@blocks_by_path.keys
@callbacks_by_path.keys
end

def process_changed_files(changed_files)
changed_files.each do |file|
@blocks_by_path.each do |path, blocks|
@callbacks_by_path.each do |path, callbacks|
if file.to_s.start_with?(path.to_s)
blocks.each { |action| action.call(file) }
callbacks.each { |callback| callback.call(file) }
end
end
end
Expand Down

0 comments on commit e3fa36e

Please sign in to comment.