From: John Wilger Date: 2008-03-05T14:44:54+09:00 Subject: Re: Inspecting a block given to a method On Mar 4, 4:56 pm, Thomas Mueller wrote: > Thanks for your quick reply. If I understand you correctly that would > result in something like this being executed: > > bc.find_all(search_specs) do |record| >   activate("field1")  # this is what the proxy object would do >   record["field1"] = "some value" >   activate("field2")  # this is what the proxy object would do >   puts record["field2"] > end > > That wouldn't work because the fields need to be activated before I > query the data, basically before or at the beginning of the find_all() > method. > My find_all() looks something like this: > > def find_all >   self.clear_to_query() >   self.set_search_spec(...) # several of those, based on arguments to find_all() >   self.execute_query() > >   begin >     yield self >   end while self.next_record() if self.first_record() > end You could instead yield to the given block /before/ doing the actual query and pass in an object which would simply record the method calls. Then you could figure out the fields that need to be activated from that, do the query, and replay the method calls on the actual records returned. This would get difficult if you tried to do anything beyond basic one-liners within the block, but it might work. -- Regards, John Wilger