Class: Filbunke::Callbacks
- Inherits:
-
Object
- Object
- Filbunke::Callbacks
- Defined in:
- lib/filbunke/callbacks.rb
Instance Method Summary collapse
-
#initialize(logger, config = {}) ⇒ Callbacks
constructor
A new instance of Callbacks.
- #on_delete(file, local_file_path) ⇒ Object
- #on_delete_batch(files) ⇒ Object
- #on_no_change(file, local_file_path) ⇒ Object
- #on_no_change_batch(files) ⇒ Object
- #on_update(file, local_file_path) ⇒ Object
- #on_update_batch(files) ⇒ Object
Constructor Details
#initialize(logger, config = {}) ⇒ Callbacks
Returns a new instance of Callbacks.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/filbunke/callbacks.rb', line 4 def initialize(logger, config = {}) @config = config @logger = logger num_callback_threads = @config["num_callback_threads"].to_i num_callback_processes = @config["num_callback_processes"].to_i if num_callback_threads == 0 and num_callback_processes == 0 @config["num_callback_threads"] = Parallel.processor_count end @parallel_callback_opts = (num_callback_threads > 0 ? {:in_threads => num_callback_threads} : {:in_processes => num_callback_processes}) end |
Instance Method Details
#on_delete(file, local_file_path) ⇒ Object
36 37 |
# File 'lib/filbunke/callbacks.rb', line 36 def on_delete(file, local_file_path) end |
#on_delete_batch(files) ⇒ Object
31 32 33 34 35 |
# File 'lib/filbunke/callbacks.rb', line 31 def on_delete_batch(files) Parallel.map(files, @parallel_callback_opts) do |item| on_delete(item.file, item.local_file_path) end end |
#on_no_change(file, local_file_path) ⇒ Object
28 29 |
# File 'lib/filbunke/callbacks.rb', line 28 def on_no_change(file, local_file_path) end |
#on_no_change_batch(files) ⇒ Object
23 24 25 26 27 |
# File 'lib/filbunke/callbacks.rb', line 23 def on_no_change_batch(files) Parallel.map(files, @parallel_callback_opts) do |item| on_no_change(item.file, item.local_file_path) end end |
#on_update(file, local_file_path) ⇒ Object
20 21 |
# File 'lib/filbunke/callbacks.rb', line 20 def on_update(file, local_file_path) end |
#on_update_batch(files) ⇒ Object
15 16 17 18 19 |
# File 'lib/filbunke/callbacks.rb', line 15 def on_update_batch(files) Parallel.map(files, @parallel_callback_opts) do |item| on_update(item.file, item.local_file_path) end end |