From: Kent Sibilev Date: 2004-09-26T10:16:34+09:00 Subject: Re: mixin with A::B syntax The reason for this error is that Mysql is defined as class not module. Try to change your example to: class Mysql class Result def foo print "This is foo\n" end end end Cheers, Kent. On Sep 25, 2004, at 9:09 PM, eagle eyes joe wrote: > Greetings, > > I still can't get this syntax to work. Here is a smaller program > that I am trying to get to run. Thank you for all your help. > > > This is the error message I get: > > > > [Abba:/tmp] josephal% ./test > ../test:5: Mysql is not a module (TypeError) > > > > > > [Abba:/tmp] josephal% cat ./test > #!/usr/bin/ruby > > require 'mysql' > > module Mysql > class Result > def foo > print "This is foo\n" > end > end > end > > m = Mysql.new("localhost", "root", "", "Development") > > r = m.query("select * from processedfiles limit 5") > > r.foo > > > [Abba:/tmp] josephal% > > > > > > > From: dblack@wobblini.net > Subject: Re: mixin with A::B syntax > Date: September 23, 2004 7:40:38 PM CDT > To: undisclosed-recipients: ; > > Hi -- > > On Fri, 24 Sep 2004, Brian Schroeder wrote: > > On Thu, 23 Sep 2004 19:52:01 +0000, eagle eyes joe wrote: > > Greetings, > > I want to define a generic print method to use in debugging. I got the > mix in syntax okay for classes like Hash or String, but for > Mysql::Result, > it doesn't seem to work. What would the proper syntax be? > > > Joe Alotta > > > #!/usr/bin/ruby > > require 'mysql' > > class Mysql::Result > def print > self.each_hash do |i| > i.each do |k, v| { print "#{k} = #{v} "} puts > > end > end > end > > m = Mysql.new("localhost", "root", "", "Development") > > s = m.query("select * from symbols where type = 'MU'") > > s.print > > > Joe Alotta > > module Mysql > class Result > def print > [...] > end > end > end > > I believe that should have the same effect as Joe's example. The only > difference between going one at a time and doing Mysql::Result is the > scope of constants. > > > David > > -- > David A. Black > dblack@wobblini.net >