Fiber::Storage SourceFiberStorage

module Storage

Provides compatibility shims for fiber storage.

Definitions

def initialize(*arguments, storage: true, **options, &block)

Initialize the fiber with the given storage.

Implementation

def initialize(*arguments, storage: true, **options, &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, **options, &block)
end

def storage=(hash)

Set the storage associated with this fiber, clearing any previous storage.

Implementation

def storage=(hash)
	@storage = hash.dup
end

def storage

The storage associated with this fiber.

Implementation

def storage
	@storage.dup
end

def __storage__

  • private

Signature

private

Implementation

def __storage__
	@storage ||= {}
end