binlib/sql/template: add 'locals' method.

This commit is contained in:
0x1eef 2022-10-07 15:25:02 -03:00
parent afb2c4fccc
commit 949ef49bf0

View file

@ -7,8 +7,7 @@ class SQL::Template
def context def context
context = binding context = binding
context.local_variable_set(:languages, %w[ar en pt fa].map { SQL::Language.new(_1) }) locals.each { context.local_variable_set(_1, _2) }
context.local_variable_set(:chapter_id, 1)
context context
end end
@ -26,4 +25,13 @@ class SQL::Template
chapter_id, verse.content chapter_id, verse.content
].map { Integer === _1 ? _1 : SQL::Utils.escape(_1) }.join(",") ].map { Integer === _1 ? _1 : SQL::Utils.escape(_1) }.join(",")
end end
private
def locals
{
languages: %w(ar en pt fa).map { SQL::Language.new(_1) },
chapter_id: 1
}
end
end end