From: Dhruva Sagar Date: 2010-05-20T11:08:26+09:00 Subject: Re: define_method inside instance_eval --001636c5a2f54197030486fd0ced Content-Type: text/plain; charset=UTF-8 You can do this : def status_field(*args) instance_eval { define_method(:status_all) {|*args| "#{args.join(' ')}".split } } end or you can do this : def status_field(*args) class << self def status_all(*args) "#{args.join(' ')}".split end end end On Thu, May 20, 2010 at 07:28, Adriano Nagel wrote: > Dhruva Sagar wrote: > > Should be > > > > instance_eval %{ > > def status_all(*args) > > "#{args.join(' ')}".split > > end > > } > > Sorry, I wasn't clear. This snippet is actually wrapped inside the class > macro, like this: > > def status_field(*args) > instance_eval %{ > def status_all > "#{args.join(' ')}".split > end > } > end > > Thanks, > > -- > Adriano > -- > Posted via http://www.ruby-forum.com/. > > -- Thanks & Regards, Dhruva Sagar. --001636c5a2f54197030486fd0ced--