Class: AWS::Flow::Core::FlowFiber
- Inherits:
-
Fiber
- Object
- Fiber
- AWS::Flow::Core::FlowFiber
- Defined in:
- lib/aws/flow/fiber.rb
Direct Known Subclasses
BeginRescueEnsure, BeginRescueEnsureWrapper, ExternalTask, Task
Class Attribute Summary collapse
-
.local_variables ⇒ Object
Returns the value of attribute local_variables.
Class Method Summary collapse
- .[](index) ⇒ Object
- .[]=(key, value) ⇒ Object
- .finalize(obj_id) ⇒ Object
-
.unset(current_fiber, key) ⇒ Object
Will unset all the values for ancestors of this fiber, assuming that they have the same value for key.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize ⇒ FlowFiber
constructor
A new instance of FlowFiber.
Constructor Details
#initialize ⇒ FlowFiber
Returns a new instance of FlowFiber.
22 23 24 25 |
# File 'lib/aws/flow/fiber.rb', line 22 def initialize(*args) ObjectSpace.define_finalizer(self, self.class.finalize(self.object_id)) super(args) end |
Class Attribute Details
.local_variables ⇒ Object
Returns the value of attribute local_variables.
27 28 29 |
# File 'lib/aws/flow/fiber.rb', line 27 def local_variables @local_variables end |
Class Method Details
.[](index) ⇒ Object
33 34 35 |
# File 'lib/aws/flow/fiber.rb', line 33 def self.[](index) self.local_variables[index] end |
.[]=(key, value) ⇒ Object
36 37 38 |
# File 'lib/aws/flow/fiber.rb', line 36 def self.[]=(key, value) self.local_variables[key] = value end |
.finalize(obj_id) ⇒ Object
30 31 32 |
# File 'lib/aws/flow/fiber.rb', line 30 def self.finalize(obj_id) proc { FlowFiber.local_variables.delete(obj_id) } end |
.unset(current_fiber, key) ⇒ Object
Will unset all the values for ancestors of this fiber, assuming that they have the same value for key. That is, they will unset upwards until the first time the value stored at key is changed
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/aws/flow/fiber.rb', line 43 def self.unset(current_fiber, key) current_value = FlowFiber[current_fiber.object_id][key] parent = FlowFiber[current_fiber.object_id][:parent] ancestor_fibers = [] while parent != nil ancestor_fibers << parent parent = FlowFiber[parent.object_id][:parent] end ancestor_fibers.each do |fiber| FlowFiber[fiber.object_id].delete(key) if FlowFiber[fiber.object_id][key] == current_value end FlowFiber[current_fiber.object_id].delete(key) end |