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.
31 32 33 34 |
# File 'lib/fibre/scope.rb', line 31 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
.await {|mock| ... } ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/fibre/scope.rb', line 22 def await scope = Fiber.current[:scope] mock = Fibre::Mock.new(scope) scope.mocks << mock yield(mock) if block_given? mock end |
.in_scope? ⇒ Boolean
18 19 20 |
# File 'lib/fibre/scope.rb', line 18 def in_scope? !!Fiber.current[:scope] end |
Instance Method Details
#check ⇒ Object
36 37 38 |
# File 'lib/fibre/scope.rb', line 36 def check fiber.resume if @mocks.all?(&:completed?) end |