I'm not exactly sure what you are trying to do. Do any of these do what
you want? And by "better" are you meaning faster, easier to maintain,
more robust, or...?
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
--
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
module_eval <<-"end_eval", __FILE__, __LINE__
def foo
some_method_which_expects_a_hash(#{options})
end
end_eval
I'm not exactly sure what you are trying to do. Do any of these do what
you want? And by "better" are you meaning faster, easier to maintain,
more robust, or...?
well, basically just not so breakable. inspecting and then replacing \" just
doesnt sound so safe..
foo = method("#{foo}_method_which_expects_a_hash")
define_method(:foo) do
foo.call(options)
end
# I forgot "do".
awesome! thanks a lot!
i was wondering, are there any differences concerning
performance when the method is called.. or is it the same
wether the method is created with eval or with define_method?