Skip to content

Commit 7b26461

Browse files
committed
rename find_classes_by_superclass to find_classes_by_ancestor
1 parent 6aa938b commit 7b26461

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

lib/helpers/parse_ruby.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# ruby/parser helper parses ruby files and saves the :ruby_definitions to data.
44
# The :ruby_definitions is an object of RubyDefinitions,
55
# which contains all the classes, modules, methods, constants, ancestors,
6-
# and provides some methods, such as find_classes_by_superclass.
6+
# and provides some methods, such as find_classes_by_ancestor.
77
Synvert::Helper.new 'ruby/parse' do |options|
88
configure(parser: Synvert::PRISM_PARSER)
99

@@ -87,7 +87,7 @@
8787
class RubyDefinitions
8888
attr_reader :node
8989

90-
delegate :setup_ancestors, :find_classes_by_superclass, :to_h, to: :@root
90+
delegate :setup_ancestors, :find_classes_by_ancestor, :to_h, to: :@root
9191

9292
def initialize
9393
@root = RootDefinition.new
@@ -155,10 +155,10 @@ def current_node_type
155155
end
156156

157157
class BaseDefinition
158-
def find_classes_by_superclass(superclass)
158+
def find_classes_by_ancestor(superclass)
159159
@classes.select { |klass| klass.ancestors.include?(superclass) } +
160-
@classes.flat_map { |klass| klass.find_classes_by_superclass(superclass) } +
161-
@modules.flat_map { |mod| mod.find_classes_by_superclass(superclass) }
160+
@classes.flat_map { |klass| klass.find_classes_by_ancestor(superclass) } +
161+
@modules.flat_map { |mod| mod.find_classes_by_ancestor(superclass) }
162162
end
163163

164164
def full_name

lib/rails/perform_job_in_after_commit_callback.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ def send_notification
3131

3232
call_helper 'ruby/parse'
3333
definitions = load_data :ruby_definitions
34-
job_classes = definitions.find_classes_by_superclass('ApplicationJob').map(&:full_name) +
35-
definitions.find_classes_by_superclass('Sidekiq::Job').map(&:full_name)
36-
mailer_classes = definitions.find_classes_by_superclass('ApplicationMailer').map(&:name)
34+
job_classes = definitions.find_classes_by_ancestor('ApplicationJob').map(&:full_name) +
35+
definitions.find_classes_by_ancestor('Sidekiq::Job').map(&:full_name)
36+
mailer_classes = definitions.find_classes_by_ancestor('ApplicationMailer').map(&:name)
3737

3838
within_files Synvert::RAILS_MODEL_FILES do
3939
find_node '.class_node' do

spec/helpers/parse_ruby_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class UserJob < SynvertJob
124124
rewriter.process
125125

126126
definitions = rewriter.load_data(:ruby_definitions)
127-
classes = definitions.find_classes_by_superclass('ApplicationJob')
127+
classes = definitions.find_classes_by_ancestor('ApplicationJob')
128128
expect(classes.map(&:full_name)).to eq(['SynvertJob', 'Synvert::UserJob'])
129129
end
130130
end

0 commit comments

Comments
 (0)