From: James Byrne Date: 2009-04-22T23:32:25+09:00 Subject: Trouble with module/class inheritance I have a class "ForexCASource" that does this: class ForexCASource include Nokogiri::XML def initializer(... ... return xchg_source end # Takes an xml source, default set to FOREX_SITE # Returns a nokogiri xml document object def xchg_source(source=FOREX_SITE) @forex_doc = Nokogiri::XML(open(source)) rescue Exception => e puts e Rails::logger.error("ForexCASource unable to read #{source} \n #{e}") raise e end ... When new is called on this class (fx_xml_doc = ForexCASource.new) then I expect to receive @forex_doc, which has a class of "Nokogiri::XML::Document", and an inherited public method '#xpath'. However, while the returned object has class ForexCASource, which is to be expected, I do not get the #xpath method attached to the returned object, which is not what I expected. When I examine the returned object then I see: puts fx_xml_doc.class.ancestors ForexCASource Nokogiri::XML Object This is critically different than "Nokogiri::XML::Document". What changes the ancestor of @forex_doc from Nokogiri::XML::Document to Nokogiri::XML and removes the #xpath method? What is it about inheritance/mixin am I not understanding? -- Posted via http://www.ruby-forum.com/.