Project

General

Profile

Feature #8643

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

`Binding.from_hash` Binding.from_hash would work like: 

 ```ruby 
 class Binding 
   def self.from_hash(hash) 
     OpenStruct.new(hash){ binding } 
   end 
 end 
 ``` 

 It would simplify things like: 

 `ERB.new(IO.read ERB.new(IO.read 'template.erb').result Binding.from_hash(template_local: 'example')` 'example') 

 Or if you need to `eval` eval some code in another process (JRuby, for instance) and need to pass some arguments to the `eval` eval code in a hash form. 

 I didn't want to pollute `Hash` Hash by adding `Hash#to_binding`. Hash#to_binding. I believe `Binding.from_hash` Binding.from_hash is more appropriate.

Back