Skip to content

Commit 8ea3f58

Browse files
fix: rubocop
1 parent 1fe9642 commit 8ea3f58

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/chewy/index/witchcraft.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,7 @@ def proc_fields_for(parent, nesting)
172172
end
173173

174174
def source_for(proc, nesting)
175-
ast = if defined?(Prism)
176-
Prism::Translation::ParserCurrent.parse(proc.source)
177-
else
178-
Parser::CurrentRuby.parse(proc.source)
179-
end
180-
lambdas = exctract_lambdas(ast)
175+
lambdas = exctract_lambdas(ast_from_proc(proc))
181176

182177
raise "No lambdas found, try to reformat your code:\n`#{proc.source}`" unless lambdas
183178

@@ -204,6 +199,14 @@ def source_for(proc, nesting)
204199
Unparser.unparse(source)
205200
end
206201

202+
def ast_from_proc(proc)
203+
if defined?(Prism)
204+
Prism::Translation::ParserCurrent.parse(proc.source)
205+
else
206+
Parser::CurrentRuby.parse(proc.source)
207+
end
208+
end
209+
207210
def exctract_lambdas(node)
208211
return unless node.is_a?(Parser::AST::Node)
209212

0 commit comments

Comments
 (0)