From: Kent Dahl Date: 2003-02-21T04:59:47+09:00 Subject: Re: Extending existing classes under mod_ruby... Frank Fejes wrote: > ---------------- > > #!/usr/local/ruby/bin/ruby > > class String > def test_me? > self.length > 0 > end > end > > # we are in mod_ruby if $? is false > puts "Content-type: text/plain\n\n" unless not $0 > > print "String responds to test_me?: " > puts 'a'.respond_to?(:test_me?) > > ---------------- This is not the String class your are looking for. In mod_ruby, the scripts are wrapped in an anonymous module, so you are effectively creating a new class called String, but inside module. Try puts String.new.respond_to?(:test_me?) in your script. How to get the desired behaviour? Move it out of your code and into a required file. Then realize that this will affect all running Apache instances and all applications served by them. Consider it a bad thing all together, or require the file in the httpd.conf itself, so that other hapless coders understand why the default String class is acting funky without searching across the complete harddisk. (Hapless coders include you in the future :-) -- (\[ Kent Dahl ]/)_ _~_ __[ http://www.stud.ntnu.no/~kentda/ ]___/~ ))\_student_/(( \__d L b__/ NTNU - graduate engineering - 5. year ) ( \__\_�|�_/__/ ) _)Industrial economics and technological management( \____/_�_\____/ (____engineering.discipline_=_Computer::Technology___)