class SystemNavigation::AncestorMethodFinder
Public Class Methods
find_all_ancestors(of:)
click to toggle source
# File lib/system_navigation/ancestor_method_finder.rb, line 5 def self.find_all_ancestors(of:) finder = self.new(of) singleton_finder = self.new(of.singleton_class) ancestor_list = [] ancestor_list.concat(finder.find_all_methods) ancestor_list.concat(singleton_finder.find_all_methods) ancestor_list end
new(behavior)
click to toggle source
# File lib/system_navigation/ancestor_method_finder.rb, line 17 def initialize(behavior) @behavior = behavior @ancestor_list = behavior.ancestors - [behavior] end
Public Instance Methods
find_all_methods()
click to toggle source
# File lib/system_navigation/ancestor_method_finder.rb, line 22 def find_all_methods self.find_closest_ancestors(@ancestor_list).flat_map do |ancestor| selectors = MethodHash.create(based_on: ancestor, include_super: false) # No inheritance for singletons in Ruby [:public, :private, :protected].each { |t| selectors[t][:singleton] = [] } MethodQuery.execute(collection: selectors, query: :convert_to_methods, behavior: @behavior) end end
Protected Instance Methods
find_closest_ancestors(ancestors)
click to toggle source
# File lib/system_navigation/ancestor_method_finder.rb, line 36 def find_closest_ancestors(ancestors) if @behavior.is_a?(Class) ancestors.split(@behavior.superclass).first || [] else ancestors end end