Class: Adrian::Worker
- Inherits:
-
Object
- Object
- Adrian::Worker
- Defined in:
- lib/adrian/worker.rb
Instance Attribute Summary collapse
-
#item ⇒ Object
readonly
Returns the value of attribute item.
Instance Method Summary collapse
-
#initialize(item) ⇒ Worker
constructor
A new instance of Worker.
- #perform ⇒ Object
- #report_to(boss) ⇒ Object
- #work ⇒ Object
Constructor Details
#initialize(item) ⇒ Worker
Returns a new instance of Worker.
5 6 7 |
# File 'lib/adrian/worker.rb', line 5 def initialize(item) @item = item end |
Instance Attribute Details
#item ⇒ Object (readonly)
Returns the value of attribute item.
3 4 5 |
# File 'lib/adrian/worker.rb', line 3 def item @item end |
Instance Method Details
#perform ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/adrian/worker.rb', line 13 def perform exception = nil begin work rescue Exception => e exception = e end @boss.work_done(item, self, exception) if @boss end |
#report_to(boss) ⇒ Object
9 10 11 |
# File 'lib/adrian/worker.rb', line 9 def report_to(boss) @boss = boss end |
#work ⇒ Object
25 26 27 |
# File 'lib/adrian/worker.rb', line 25 def work raise "You need to implement #{self.class.name}#work" end |