From: Marnen Laibow-Koser Date: 2009-11-26T00:42:56+09:00 Subject: Re: Help with meta programming Sean Shillo wrote: > I came across the following code in a class called Marker > > def when_dropped > self.listen_to :event => :dragend do |script| > script << "drop_location = #{self.var}.getLatLng();" > > yield script, :drop_location > end > end > > if i use the function as follows > > marker.when_dropped do |script, drop_location| > logger.info(drop_location) > end > > all i get is "drop_location". Right -- because the parameter is the literal value :drop_location, not a variable. > I want drop_location to be evaluated to > get the value from #{self.var}.getLatLng() and I can't seem to find a > way to do this, anyone have any ideas and/or know The getLatLng looks like it's JavaScript, not Ruby. I'm assuming this is in the context of RJS or something that builds JS source code as a Ruby string. If that's the case, then you'll need to do the logging of that value on the JS side -- Ruby can't evaluate JS for you. > what exactly is going on here. You're getting confused about what part of your code is in which language. > > Thanks Best, -- Marnen Laibow-Koser http://www.marnen.org marnen@marnen.org -- Posted via http://www.ruby-forum.com/.