Class: Tobox::Worker
- Inherits:
-
Object
- Object
- Tobox::Worker
- Defined in:
- lib/tobox/worker.rb
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
Instance Method Summary collapse
- #finish! ⇒ Object
- #finished? ⇒ Boolean
-
#initialize(label, configuration) ⇒ Worker
constructor
A new instance of Worker.
- #work ⇒ Object
Constructor Details
#initialize(label, configuration) ⇒ Worker
Returns a new instance of Worker.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/tobox/worker.rb', line 7 def initialize(label, configuration) @label = label @wait_for_events_delay = configuration[:wait_for_events_delay] @handlers = configuration.handlers || {} @fetcher = configuration.fetcher_class.new(label, configuration) @finished = false return unless ( = configuration.arguments_handler) define_singleton_method(:message_to_arguments, &) end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
5 6 7 |
# File 'lib/tobox/worker.rb', line 5 def label @label end |
Instance Method Details
#finish! ⇒ Object
23 24 25 |
# File 'lib/tobox/worker.rb', line 23 def finish! @finished = true end |
#finished? ⇒ Boolean
19 20 21 |
# File 'lib/tobox/worker.rb', line 19 def finished? @finished end |
#work ⇒ Object
27 28 29 |
# File 'lib/tobox/worker.rb', line 27 def work do_work until @finished end |