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
=> #Proc:0x40221e48@:1(irb)
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