From: Ara.T.Howard@... Date: 2004-09-09T04:25:06+09:00 Subject: Re: using a hash in eval On Thu, 9 Sep 2004, Florian Weber wrote: > hi! > > is there a better way to do this: > > options = <<-END_OF_OPTIONS > #{options.inspect} > END_OF_OPTIONS > options.gsub!("\\\"", "'") > > module_eval <<-"end_eval", __FILE__, __LINE__ > def foo > some_method_which_expects_a_hash(#{options}) > end > end_eval > > i guess iterating over each key and value and writing it 'by hand' is > the only way, right? > > thanks! > > ciao! > flroian some_method_which_expects_a_hash(YAML::load("#{ YAML::dump options }")) or even some_method_which_expects_a_hash(Marshal::load("#{ Marshal::dump options }")) maybe. -a -- =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | A flower falls, even though we love it; | and a weed grows, even though we do not love it. | --Dogen ===============================================================================