Module: Fiber::Storage
- Included in:
- Fiber
- Defined in:
- lib/fiber/storage.rb,
lib/fiber/storage/version.rb
Overview
Provides compatibility shims for fiber storage.
Constant Summary collapse
- VERSION =
"1.0.1"
Instance Method Summary collapse
- #__storage__ ⇒ Object
-
#initialize(*arguments, storage: true, **options, &block) ⇒ Object
Initialize the fiber with the given storage.
-
#storage ⇒ Object
The storage associated with this fiber.
-
#storage=(hash) ⇒ Object
Set the storage associated with this fiber, clearing any previous storage.
Instance Method Details
#__storage__ ⇒ Object
37 38 39 |
# File 'lib/fiber/storage.rb', line 37 def __storage__ @storage ||= {} end |
#initialize(*arguments, storage: true, **options, &block) ⇒ Object
Initialize the fiber with the given storage.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fiber/storage.rb', line 13 def initialize(*arguments, storage: true, **, &block) case storage when true @storage = Fiber.current.storage else raise TypeError, "Storage must be a hash!" unless storage.is_a?(Hash) @storage = storage end super(*arguments, **, &block) end |
#storage ⇒ Object
The storage associated with this fiber.
32 33 34 |
# File 'lib/fiber/storage.rb', line 32 def storage @storage.dup end |
#storage=(hash) ⇒ Object
Set the storage associated with this fiber, clearing any previous storage.
27 28 29 |
# File 'lib/fiber/storage.rb', line 27 def storage=(hash) @storage = hash.dup end |