Class: AWS::Flow::Core::FlowFiber

Inherits:
Fiber
  • Object
show all
Defined in:
lib/aws/flow/fiber.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFlowFiber

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_variablesObject

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

Instance Method Details

#[](key) ⇒ Object



66
67
68
# File 'lib/aws/flow/fiber.rb', line 66

def [](key)
  FlowFiber[self.object_id][key]
end

#[]=(key, value) ⇒ Object



69
70
71
# File 'lib/aws/flow/fiber.rb', line 69

def []=(key, value)
  FlowFiber[self.object_id][key] = value
end