From: Ross X Dawson Date: 2007-10-12T08:13:40+09:00 Subject: Re: Using strings to drill down into objects --0__=45BBF9E2DFED79318f9e8a93df938690918c45BBF9E2DFED7931 Content-type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sorry folks the example was not correct irb(main):001:0> drill_down = lambda do |obj, method_names| irb(main):002:1* o ||= obj irb(main):003:1> method_names.split('.').each {|m| o = o.send(m)} irb(main):004:1> o irb(main):005:1> end => # irb(main):006:0> drill_down.call(1,'succ.to_s') => "2" irb(main):007:0> drill_down.call(1,'succ.succ.succ.to_s') => "4" irb(main):008:0> This is what I currently have working. I'm using it to define the columns in a report so I need to determine the result of arbitrary fields within the object model. I just look at the code and think there is a better way. ********************************************************************** This communication may contain CONFIDENTIAL information and may also be the subject of LEGAL PROFESSIONAL PRIVILEGE and/or under copyright. If you are not an intended recipient, you MUST NOT keep, forward, copy, use, save or rely on this communication and any such action is unauthorised and prohibited. If you have received this communication in error, please reply to this e-mail to notify the sender of its incorrect delivery, and then delete both it and your reply. Thank you ********************************************************************** --0__=45BBF9E2DFED79318f9e8a93df938690918c45BBF9E2DFED7931--