module T::Private::Methods

def self.visibility_method_name(mod, name)

`name` must be an instance method (for class methods, pass in mod.singleton_class)
def self.visibility_method_name(mod, name)
  if mod.public_method_defined?(name)
    :public
  elsif mod.protected_method_defined?(name)
    :protected
  elsif mod.private_method_defined?(name)
    :private
  else
    # Raises a NameError formatted like the Ruby VM would (the exact text formatting
    # of these errors changed across Ruby VM versions, in ways that would sometimes
    # cause tests to fail if they were dependent on hard coding errors).
    mod.method(name)
  end
end