Class: RactorRailsShim::NoOpProc

Inherits:
Object
  • Object
show all
Defined in:
lib/ractor_rails_shim/patches/callables.rb

Constant Summary collapse

NO_OP_LAMBDA =

A NoOpProc is a shareable stand-in for an arbitrary Proc in the app graph. Some Rails code passes such values through &block, which calls #to_proc and then requires the result to be a real Proc. Return a frozen no-op lambda so the implicit conversion succeeds and the (side-effect-free) call is a true no-op, matching #call.

The lambda is a shareable constant (frozen at class load), NOT memoized on @_to_proc: NoOpProc instances are deep-frozen by Ractor.make_shareable during make_app_shareable!, so an @_to_proc ||= ... write would raise FrozenError on the frozen instance. A constant avoids the write entirely and is safe to share.

->(*) { nil }.freeze

Instance Method Summary collapse

Instance Method Details

#call(*_) ⇒ Object



15
# File 'lib/ractor_rails_shim/patches/callables.rb', line 15

def call(*_); nil; end

#to_procObject



29
30
31
# File 'lib/ractor_rails_shim/patches/callables.rb', line 29

def to_proc
  NO_OP_LAMBDA
end