Skip to content
Permalink
Browse files

Merge pull request #724 from jstepien/instance_methods

Module#(public_|)instance_methods
  • Loading branch information
alex committed May 22, 2013
2 parents 881a145 + 738045c commit d2f7b36030c4520c5c357fb97a412c0ec070c481
@@ -1,7 +1 @@
fails:Module#instance_methods does not return methods undefined in a superclass
fails:Module#instance_methods does not return methods undefined in a subclass
fails:Module#instance_methods does not return methods undefined in the current class
fails:Module#instance_methods does not return methods from an included module that are undefined in the class
fails:Module#instance_methods returns the public and protected methods of self if include_super is false
fails:Module#instance_methods returns the public and protected methods of self and it's ancestors
fails:Module#instance_methods makes a private Object instance method public in Kernel
@@ -1,7 +1,2 @@
fails:Module#public_instance_methods returns a list of public methods in module and its ancestors
fails:Module#public_instance_methods when passed false as a parameter, should return only methods defined in that module
fails:Module#public_instance_methods default list should be the same as passing true as an argument
fails:Module#public_instance_methods when not passed an argument returns a unique list for a class including a module
fails:Module#public_instance_methods when not passed an argument returns a unique list for a subclass
fails:Module#public_instance_methods when passed true returns a unique list for a class including a module
fails:Module#public_instance_methods when passed true returns a unique list for a subclass
@@ -678,6 +678,21 @@ def method_comparison(self, space, w_other):
def method_instance_method(self, space, name):
return space.newmethod(name, self)

def instance_methods(self):
return self.methods_w.keys()

@classdef.method("public_instance_methods", include_super="bool")
@classdef.method("instance_methods", include_super="bool")
def method_instance_methods(self, space, include_super=True):
methods = {}
for module in self.included_modules:
for method in module.instance_methods():
methods[method] = None
for method in self.instance_methods():
if not isinstance(self.methods_w[method], UndefMethod):
methods[method] = None
return space.newarray([space.newsymbol(sym) for sym in methods])

@classdef.method("undef_method", name="symbol")
def method_undef_method(self, space, name):
w_method = self.find_method(space, name)

0 comments on commit d2f7b36

Please sign in to comment.
You can’t perform that action at this time.