al-quran.reflectslight.io/tasks.lib/erb_context.rb

23 lines
320 B
Ruby
Raw Normal View History

2023-03-14 22:24:33 +01:00
##
# frozen_string_literals: true
require_relative "pf"
class ERBContext
include PF
def self.with_locals(locals)
new(locals).context
end
def initialize(locals)
@locals = locals
end
def context
binding.tap do |b|
Ryo.each(@locals) { |k,v| b.local_variable_set(k, v) }
end
end
end