From 949ef49bf0a9cfadfb05028c4c2661121bad692a Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Fri, 7 Oct 2022 15:25:02 -0300 Subject: [PATCH] binlib/sql/template: add 'locals' method. --- binlib/sql/template.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/binlib/sql/template.rb b/binlib/sql/template.rb index 2d6a2b9..8230e49 100644 --- a/binlib/sql/template.rb +++ b/binlib/sql/template.rb @@ -7,8 +7,7 @@ class SQL::Template def context context = binding - context.local_variable_set(:languages, %w[ar en pt fa].map { SQL::Language.new(_1) }) - context.local_variable_set(:chapter_id, 1) + locals.each { context.local_variable_set(_1, _2) } context end @@ -26,4 +25,13 @@ class SQL::Template chapter_id, verse.content ].map { Integer === _1 ? _1 : SQL::Utils.escape(_1) }.join(",") end + + private + + def locals + { + languages: %w(ar en pt fa).map { SQL::Language.new(_1) }, + chapter_id: 1 + } + end end