# frozen_string_literal: true require 'drb' Class.include UU::Remotable module DRb class DRbObject alias __orig_method_missing method_missing def method_missing(*args, &blk) # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing __orig_method_missing(*args, &blk) rescue DRb::DRbConnError, Errno::ECONNREFUSED sleep 0.1 retry end end end module UU class RemoteHelper def initialize @mutex = Mutex.new @count = 0 end attr_reader :count def disable @mutex.synchronize do @count += 1 GC.disable end end def enable @mutex.synchronize do @count -= 1 break unless @count <= 0 GC.enable end end def reset @mutex.synchronize do @count = 0 GC.enable end end def eval_(code) instance_eval(code) end def klass(name) eval_(name.to_s) end end end