def ensure_sendable(object, depth = 1)
      case
      when exposed_local?(object)
      when exposed_remote?(object)
        reference = convert_object_to_reference(object)
        raise StaleObjectError unless reference.sendable?
      #when object.is_a?(RemoteObjectChild) || LocalObjectChild.local_object_child?(object)
      #  ExposedChild
      when object == nil
      when object.one_of?(false, true)
      when object.is_a?(Exception)
        raise UnexposedObjectError unless object.message == nil || object.message.is_a?(String)
      when object.is_a?(Integer)
      when object.is_a?(Float)
      when object.is_a?(String)
      when object.is_a?(Array)
        raise UnexposedObjectError, 'object nesting too deep' if (depth + 1) > MAX_OBJECT_NESTING_DEPTH
        object.each { |element| ensure_sendable(element, depth + 1) }
      when object.is_a?(Hash)
        raise UnexposedObjectError, 'object nesting too deep' if (depth + 1) > MAX_OBJECT_NESTING_DEPTH
        object.to_a.flatten(1).each { |item| ensure_sendable(item, depth + 1) }
      else
        raise UnexposedObjectError
      end
    end
def ensure_sendable(object, depth = 1)
      case
      when exposed_local?(object)
      when exposed_remote?(object)
        reference = convert_object_to_reference(object)
        raise StaleObjectError unless reference.sendable?
      #when object.is_a?(RemoteObjectChild) || LocalObjectChild.local_object_child?(object)
      #  ExposedChild
      when object == nil
      when object.one_of?(false, true)
      when object.is_a?(Exception)
        raise UnexposedObjectError unless object.message == nil || object.message.is_a?(String)
      when object.is_a?(Integer)
      when object.is_a?(Float)
      when object.is_a?(String)
      when object.is_a?(Array)
        raise UnexposedObjectError, 'object nesting too deep' if (depth + 1) > MAX_OBJECT_NESTING_DEPTH
        object.each { |element| ensure_sendable(element, depth + 1) }
      when object.is_a?(Hash)
        raise UnexposedObjectError, 'object nesting too deep' if (depth + 1) > MAX_OBJECT_NESTING_DEPTH
        object.to_a.flatten(1).each { |item| ensure_sendable(item, depth + 1) }
      else
        raise UnexposedObjectError
      end
    end
Ensure that the objects can be sent.
 The object must be a supported primitive type or an {ExposedObject} that is not stale.
 @param object [Array,Boolean,Exception,ExposedObject,Float,Hash,Integer,nil,String]
 @param depth [Integer] object nesting depth
 @raise [UnexposedObjectError] if an object is an invalid type
 @raise [UnexposedObjectError] if object is nested too deep
 @raise [StaleObjectError] if an object has been forgoten by this endpoint (may not be forgoten by the remote endpoint yet)
 @return [void]