Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Module#public_method_defined? will return true when was passed name/s…

…ymbol of public method.

Test Script:
require 'test/unit/assertions.rb'
include Test::Unit::Assertions

class T
  def foo ; end
  def bar ; end
  def baz ; end

  protected :baz
  private :bar

assert_equal(true, T.public_method_defined?("foo"))
assert_equal(true, T.public_method_defined?(:foo))

assert_equal(false, T.public_method_defined?("bar"))
assert_equal(false, T.public_method_defined?(:bar))

assert_equal(false, T.public_method_defined?("baz"))
assert_equal(false, T.public_method_defined?(:baz))

puts :ok

git-svn-id: 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
commit adc48831171828bca45f78de1606c6dbfcaddad6 1 parent 0d71bd5
@Watson1978 Watson1978 authored
Showing with 1 addition and 1 deletion.
  1. +1 −1  vm_method.c
2  vm_method.c
@@ -313,7 +313,7 @@ check_method_visibility(VALUE mod, ID id, int visi)
rb_vm_method_node_t *node;
if (rb_vm_lookup_method2((Class)mod, id, NULL, NULL, &node)) {
if (node != NULL) {
- if (node->flags & rb_vm_noex_flag(visi)) {
+ if ((node->flags & NOEX_MASK) == visi) {
return Qtrue;
Please sign in to comment.
Something went wrong with that request. Please try again.