Class: Fibre::Scope
- Inherits:
-
Object
- Object
- Fibre::Scope
- Defined in:
- lib/fibre/scope.rb
Instance Attribute Summary collapse
-
#fiber ⇒ Object
Returns the value of attribute fiber.
-
#mocks ⇒ Object
Returns the value of attribute mocks.
Class Method Summary collapse
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(fiber) ⇒ Scope
constructor
A new instance of Scope.
Constructor Details
#initialize(fiber) ⇒ Scope
Returns a new instance of Scope.
30 31 32 33 |
# File 'lib/fibre/scope.rb', line 30 def initialize(fiber) @fiber = fiber @mocks = [] end |
Instance Attribute Details
#fiber ⇒ Object
Returns the value of attribute fiber.
4 5 6 |
# File 'lib/fibre/scope.rb', line 4 def fiber @fiber end |
#mocks ⇒ Object
Returns the value of attribute mocks.
3 4 5 |
# File 'lib/fibre/scope.rb', line 3 def mocks @mocks end |
Class Method Details
.scope ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/fibre/scope.rb', line 8 def scope raise "nested scopes" if Fiber.current[:scope] Fiber.current[:scope] = self.new(Fiber.current) res = yield Fiber.current[:scope] = nil Fiber.yield! res end |
.scope? ⇒ Boolean
17 18 19 |
# File 'lib/fibre/scope.rb', line 17 def scope? !!Fiber.current[:scope] end |
Instance Method Details
#check ⇒ Object
35 36 37 |
# File 'lib/fibre/scope.rb', line 35 def check fiber.resume if @mocks.all?(&:completed?) end |