Class: Innate::Fiber
- Inherits:
-
Fiber
- Object
- Fiber
- Innate::Fiber
- Defined in:
- lib/innate/state/fiber.rb
Overview
Innate subclasses Fiber to enable lightweight request/respose-cycle local variables.
We do that by adding a state Hash to the Fiber instance on initalization which can be accessed by #[], #[]= and #key?. Other Hash methods are not necessary right now but may be added.
We subclass to keep your Ruby clean and polished.
Instance Attribute Summary collapse
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(*args) ⇒ Fiber
constructor
A new instance of Fiber.
- #key?(key) ⇒ Boolean
- #keys ⇒ Object
Constructor Details
#initialize(*args) ⇒ Fiber
Returns a new instance of Fiber.
15 16 17 18 |
# File 'lib/innate/state/fiber.rb', line 15 def initialize(*args) super @state = {} end |
Instance Attribute Details
#state ⇒ Object
Returns the value of attribute state.
13 14 15 |
# File 'lib/innate/state/fiber.rb', line 13 def state @state end |
Instance Method Details
#[](key) ⇒ Object
20 21 22 |
# File 'lib/innate/state/fiber.rb', line 20 def [](key) state[key] end |
#[]=(key, value) ⇒ Object
24 25 26 |
# File 'lib/innate/state/fiber.rb', line 24 def []=(key, value) state[key] = value end |
#key?(key) ⇒ Boolean
28 29 30 |
# File 'lib/innate/state/fiber.rb', line 28 def key?(key) state.key?(key) end |
#keys ⇒ Object
32 33 34 |
# File 'lib/innate/state/fiber.rb', line 32 def keys state.keys end |