binlib/sql/template: add 'locals' method.
This commit is contained in:
parent
afb2c4fccc
commit
949ef49bf0
1 changed files with 10 additions and 2 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue