Skip to content

Instantly share code, notes, and snippets.

@ileitch
Created December 28, 2011 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ileitch/1529413 to your computer and use it in GitHub Desktop.
Save ileitch/1529413 to your computer and use it in GitHub Desktop.
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