Class: Breeder::Worker
- Inherits:
-
Object
- Object
- Breeder::Worker
- Defined in:
- lib/breeder/worker.rb
Instance Attribute Summary collapse
-
#should_stop ⇒ Object
Returns the value of attribute should_stop.
Instance Method Summary collapse
-
#do_work ⇒ Object
User-defined worker should override this.
- #run ⇒ Object
- #stop! ⇒ Object
- #stop? ⇒ Boolean
Instance Attribute Details
#should_stop ⇒ Object
Returns the value of attribute should_stop.
3 4 5 |
# File 'lib/breeder/worker.rb', line 3 def should_stop @should_stop end |
Instance Method Details
#do_work ⇒ Object
User-defined worker should override this
20 21 22 |
# File 'lib/breeder/worker.rb', line 20 def do_work raise NotImplementedError end |
#run ⇒ Object
13 14 15 16 17 |
# File 'lib/breeder/worker.rb', line 13 def run until stop? do_work end end |
#stop! ⇒ Object
9 10 11 |
# File 'lib/breeder/worker.rb', line 9 def stop! @should_stop = true end |
#stop? ⇒ Boolean
5 6 7 |
# File 'lib/breeder/worker.rb', line 5 def stop? @should_stop end |