Module: RactorShack::ShareableGuaranteed::NewOverride

Defined in:
lib/ractor_shack/shareable_guaranteed.rb

Instance Method Summary collapse

Instance Method Details

#new(*args) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/ractor_shack/shareable_guaranteed.rb', line 56

def new(*args, **, &)
  # We do not need to check opts for shareable items as this is not passed to the ractor block
  # and the only supported keyword argument at the moment is name:
  args.each.with_index do |argument, index|
    unless Ractor.shareable?(argument)
      if ShareableGuaranteed.consider_shareable.none? { |klass| argument.is_a?(klass) }
        ::Kernel.raise NonShareablePassedToConstructorError.new(argument_position: index + 1, argument:)
      end
    end
  end

  super
end