Created
December 28, 2011 19:54
-
-
Save ileitch/1529413 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/kernel/common/module.rb b/kernel/common/module.rb | |
index dffe98a..5bb7501 100644 | |
--- a/kernel/common/module.rb | |
+++ b/kernel/common/module.rb | |
@@ -168,25 +168,41 @@ class Module | |
end | |
def public_method_defined?(sym) | |
- sym = Rubinius::Type.coerce_to_symbol(sym) | |
+ sym = sym.to_str if sym.respond_to?(:to_str) | |
+ unless Rubinius::Type.object_kind_of?(sym, String) || Rubinius::Type.object_kind_of?(sym, Symbol) | |
+ raise TypeError, "#{sym.inspect} is not a Symbol" | |
+ end | |
+ | |
mod, meth = lookup_method(sym, false) | |
meth ? meth.public? : false | |
end | |
def private_method_defined?(sym) | |
- sym = Rubinius::Type.coerce_to_symbol(sym) | |
+ sym = sym.to_str if sym.respond_to?(:to_str) | |
+ unless Rubinius::Type.object_kind_of?(sym, String) || Rubinius::Type.object_kind_of?(sym, Symbol) | |
+ raise TypeError, "#{sym.inspect} is not a Symbol" | |
+ end | |
+ | |
mod, meth = lookup_method(sym, false) | |
meth ? meth.private? : false | |
end | |
def protected_method_defined?(sym) | |
- sym = Rubinius::Type.coerce_to_symbol(sym) | |
+ sym = sym.to_str if sym.respond_to?(:to_str) | |
+ unless Rubinius::Type.object_kind_of?(sym, String) || Rubinius::Type.object_kind_of?(sym, Symbol) | |
+ raise TypeError, "#{sym.inspect} is not a Symbol" | |
+ end | |
+ | |
mod, meth = lookup_method(sym, false) | |
meth ? meth.protected? : false | |
end | |
def method_defined?(sym) | |
- sym = Rubinius::Type.coerce_to_symbol(sym) | |
+ sym = sym.to_str if sym.respond_to?(:to_str) | |
+ unless Rubinius::Type.object_kind_of?(sym, String) || Rubinius::Type.object_kind_of?(sym, Symbol) | |
+ raise TypeError, "#{sym.inspect} is not a Symbol" | |
+ end | |
+ | |
mod, meth = lookup_method(sym, false) | |
meth ? meth.public? || meth.protected? : false | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment