From: Ahmed Eldawy Date: 2009-11-22T00:29:02+09:00 Subject: Re: Detective - a new ruby gem Emmm ... Actually that's how it should work. It's not a bug. What the gem actually does is opening the files where you have defined a method and extract the lines of method definition. When you define a method in irb it's not saved in any files. This means we have now way to extract its code. The same problem occurs when you define a method using eval method. The method is defined in a string variable (memory) not in a file. Provided that the above cases rarely happen in a real application, we can say that this is not a problem with Detective. Flower Born wrote: > On Sat, Nov 21, 2009 at 9:42 PM, Ahmed Eldawy > wrote: > >> Result >> >> def find_by_sql(sql) >> connection.select_all(sanitize_sql(sql), "#{name} Load")ollect! >> { |record| instantiate(record) } >> end >> >> > Interesting - just got a problem when have fun with it in irb: > > I have a simple hello.rb: > > class Foo > def bar > puts "hey" > end > end > > in irb: > >>> require 'hello' > => true >>> require 'detective' > => true >>> Detective.view_source "Foo#bar" > => " def bar\n puts "hey"\n end\n" >>> class Foo >>> def bar >>> puts "changed" >>> end >>> end > => nil >>> Detective.view_source "Foo#bar" > => "Cannot find source code" >>> Foo.new.bar > changed > > A bug or I did something wrong? > > Thanks, > Jan > > Detective is hosted on gemcutter -- Posted via http://www.ruby-forum.com/.