From: Brian Candler Date: 2010-01-26T23:40:34+09:00 Subject: Re: Why is the Binding object so useless? Tony Arcieri wrote: > = No really, why do you want to do that? > > I would like to implement a remote REPL with a stateless Ruby server and > a > non-Ruby client Your proposed feature would also make things like the ActionPack template rendering much cleaner. grep for "local_assigns" in action_view/renderable.rb (rails 2.3.x) and weep. Here is what they end up doing, where local_assigns is a hash of variable=>value bindings: def compile!(render_symbol, local_assigns) locals_code = local_assigns.keys.map { |key| "#{key} = local_assigns[:#{key}];" }.join source = <<-end_src def #{render_symbol}(local_assigns) old_output_buffer = output_buffer;#{locals_code};#{compiled_source} ensure self.output_buffer = old_output_buffer end end_src (Rails 3 is the same, but the file is action_view/template.rb and the method is compile not compile!) The above is probably what your REPL server should do. I guess what you propose wasn't implemented simply because it involves work to convert bindings between their internal representation and external forms like Hash and Marshal#dump. If you grab an existing live binding and pass it around, the conversion isn't required. -- Posted via http://www.ruby-forum.com/.