Class: Nursery::Child
- Inherits:
-
Object
- Object
- Nursery::Child
- Defined in:
- lib/nursery/child.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#nursery ⇒ Object
readonly
Returns the value of attribute nursery.
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
Instance Method Summary collapse
- #finish ⇒ Object
-
#initialize(nursery, config, job) ⇒ Child
constructor
A new instance of Child.
Constructor Details
#initialize(nursery, config, job) ⇒ Child
Returns a new instance of Child.
8 9 10 11 12 13 |
# File 'lib/nursery/child.rb', line 8 def initialize(nursery, config, job) @nursery = nursery @thread = Thread.new(&job) @thread[:nursery] = nursery @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/nursery/child.rb', line 6 def config @config end |
#nursery ⇒ Object (readonly)
Returns the value of attribute nursery.
4 5 6 |
# File 'lib/nursery/child.rb', line 4 def nursery @nursery end |
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
5 6 7 |
# File 'lib/nursery/child.rb', line 5 def thread @thread end |
Instance Method Details
#finish ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/nursery/child.rb', line 15 def finish thread.join unless self.thread == Thread.current nil rescue CancelledJob nil rescue Exception raise unless @config[:swallow_exceptions] end |