instance method
ERB#new_toplevel
new_toplevel(symbols) → new_binding
lib/erb.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/erb.rb, line 1050
def new_toplevel(vars = nil)
b = TOPLEVEL_BINDING
if vars
vars = vars.select {|v| b.local_variable_defined?(v)}
unless vars.empty?
return b.eval("tap {|;#{vars.join(',')}| break binding}")
end
end
b.dup
end
Returns a new binding based on TOPLEVEL_BINDING; used to create a default binding for a call to result.
See Default Binding.
Argument symbols is an array of symbols; each symbol symbol is defined as a new variable to hide and prevent it from overwriting a variable of the same name already defined within the binding.
See also
#make_compiler
#result
#location=
#result_with_hash
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0