1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Minor refactor of singleton_class_resolution_order

This commit is contained in:
Ryan Fitzgerald 2013-06-08 18:33:21 -07:00
parent a0f678b5b2
commit 39eaa8dbba

View file

@ -207,11 +207,9 @@ class Pry
# the lowest copy will be returned.
def singleton_class_resolution_order(klass)
ancestors = Pry::Method.safe_send(klass, :ancestors)
resolution_order = ancestors.map do |anc|
if anc.is_a?(Class)
[singleton_class_of(anc)] + singleton_class_of(anc).included_modules
end
end.compact.flatten(1)
resolution_order = ancestors.grep(Class).map do |anc|
[singleton_class_of(anc), *singleton_class_of(anc).included_modules]
end.flatten(1)
resolution_order.reverse.uniq.reverse - Class.included_modules
end