Issue #15781 has been reported by rbjl (Jan Lelis).

----------------------------------------
Feature #15781: Unify Method List Introspection?
https://bugs.ruby-lang.org/issues/15781

* Author: rbjl (Jan Lelis)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Although Ruby has many core methods for retrieving the list of methods available to an object, or to the instances of a class, I believe they have gotten a little confusing ([also see](https://idiosyncratic-ruby.com/25-meta-methodology.html)):

- `Object#methods` and `Module#instance_methods` do not include **private** methods (at the same time they do include **protected** ones). There is already `Object#public_methods` (and `Object#protected_methods`) for distinguishing visibility scope , but no way to get *all* methods of an object.
- There is the inconsistency that in most cases the argument being passed to `*_methods` methods let's you decide if you want to consider the inheritance chain, or not - But the prominent exception is `Object#methods` which instead toggles inheritance to singleton only! (for which we also have `Object#singleton_methods`)
- There is no direct API for getting a list of private singleton methods

Now that we have keyword arguments, we could provide a single API for listing methods. One way of doing so could be the [Object#shadow's methods method](https://github.com/janlelis/object_shadow#method-introspection). Having a keyword arguments based API would allow users to specify the dimensions of their requests better - should it:

- return the object's methods, or methods of its instances?
- return only methods of a specific visibility scope?
- return only methods of a specific inheritance level (e.g. only singleton, or all the way down to `BasicObject`)?

What do you think about having one unified way for retrieving an object's method list?



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>