Class: Teek::BackgroundNone::BackgroundWork Private
- Inherits:
-
Object
- Object
- Teek::BackgroundNone::BackgroundWork
- Defined in:
- lib/teek/background_none.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: TaskContext
Instance Method Summary collapse
- #close ⇒ Object private
- #done? ⇒ Boolean private
-
#initialize(app, data, worker: nil, &block) ⇒ BackgroundWork
constructor
private
A new instance of BackgroundWork.
- #on_done(&block) ⇒ Object private
- #on_message(&block) ⇒ Object private
- #on_progress(&block) ⇒ Object private
- #pause ⇒ Object private
- #paused? ⇒ Boolean private
- #resume ⇒ Object private
- #send_message(msg) ⇒ Object private
- #start ⇒ Object private
- #stop ⇒ Object private
Constructor Details
#initialize(app, data, worker: nil, &block) ⇒ BackgroundWork
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of BackgroundWork.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/teek/background_none.rb', line 19 def initialize(app, data, worker: nil, &block) @app = app @data = data @work_block = block || (worker && proc { |t, d| worker.new.call(t, d) }) @callbacks = { progress: nil, done: nil, message: nil } @message_queue = [] @started = false @done = false @paused = false end |
Instance Method Details
#close ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
69 70 71 |
# File 'lib/teek/background_none.rb', line 69 def close self end |
#done? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
73 74 75 |
# File 'lib/teek/background_none.rb', line 73 def done? @done end |
#on_done(&block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 39 40 |
# File 'lib/teek/background_none.rb', line 36 def on_done(&block) @callbacks[:done] = block maybe_start self end |
#on_message(&block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
42 43 44 45 |
# File 'lib/teek/background_none.rb', line 42 def (&block) @callbacks[:message] = block self end |
#on_progress(&block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 33 34 |
# File 'lib/teek/background_none.rb', line 30 def on_progress(&block) @callbacks[:progress] = block maybe_start self end |
#pause ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
52 53 54 55 56 |
# File 'lib/teek/background_none.rb', line 52 def pause @paused = true (:pause) self end |
#paused? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
77 78 79 |
# File 'lib/teek/background_none.rb', line 77 def paused? @paused end |
#resume ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
58 59 60 61 62 |
# File 'lib/teek/background_none.rb', line 58 def resume @paused = false (:resume) self end |
#send_message(msg) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 50 |
# File 'lib/teek/background_none.rb', line 47 def (msg) @message_queue << msg self end |
#start ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
81 82 83 84 |
# File 'lib/teek/background_none.rb', line 81 def start maybe_start self end |
#stop ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
64 65 66 67 |
# File 'lib/teek/background_none.rb', line 64 def stop (:stop) self end |