Module: RactorShack::ShareableGuaranteed

Defined in:
lib/ractor_shack/shareable_guaranteed.rb

Defined Under Namespace

Modules: InstanceOverrides, NewOverride Classes: NonShareableError, NonShareablePassedToConstructorError, NonShareableSentToRactorError

Class Method Summary collapse

Class Method Details

.consider_shareable(klass = (no_class = true)) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/ractor_shack/shareable_guaranteed.rb', line 4

def consider_shareable(klass = (no_class = true))
  if no_class
    @consider_shareable
  else
    @consider_shareable = [*@consider_shareable, klass].freeze
  end
end

.included(base) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ractor_shack/shareable_guaranteed.rb', line 12

def included(base)
  if base == Ractor || base < Ractor
    base.singleton_class.prepend NewOverride
  elsif base != Ractor::Port && !(base < Ractor::Port)
    # :nocov:
    raise "Not sure how to make something other than Ractor or Ractor::Port, or a subclass, shareable-guaranteed!"
    # :nocov:
  end

  base.prepend InstanceOverrides
end