From 4697c85ac033f59ae6deff1e7573d69041760155 Mon Sep 17 00:00:00 2001 From: Willian van der Velde Date: Tue, 14 May 2024 11:10:33 +0200 Subject: [PATCH] Move logic to private methods --- lib/arel/middleware/chain.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/arel/middleware/chain.rb b/lib/arel/middleware/chain.rb index e4a13549..bc737571 100644 --- a/lib/arel/middleware/chain.rb +++ b/lib/arel/middleware/chain.rb @@ -115,6 +115,11 @@ def to_sql(type, &block) private + def enhance_arel(sql, binds) + arel = Arel.sql_to_arel(sql, binds: binds) + Arel.enhance(arel) + end + def execute_with_middleware(sql, binds, execute_sql) check_middleware_recursion(sql) @@ -124,8 +129,7 @@ def execute_with_middleware(sql, binds, execute_sql) cache_accessor: cache_accessor, ) - arel = Arel.sql_to_arel(sql, binds: binds) - enhanced_arel = Arel.enhance(arel) + enhanced_arel = enhance_arel sql, binds executor.run(enhanced_arel, updated_context, execute_sql) end