From: Robert Klemme Date: 2010-03-24T06:57:11+09:00 Subject: Re: Module A extends Moudle B possible? On 03/23/2010 03:11 AM, Smart RoR wrote: > Can Modules extends within themselves? > > Like Class A < B is Valid, where B is another class > Module X < Y is invalid, where Y is another module? Not directly. But you can use #included like this: irb(main):001:0> module A; end => nil irb(main):002:0> module B irb(main):003:1> def self.included(cl) irb(main):004:2> cl.class_eval { include A } irb(main):005:2> end irb(main):006:1> end => nil irb(main):007:0> class X irb(main):008:1> include B irb(main):009:1> end => X irb(main):010:0> X.ancestors => [X, A, B, Object, Kernel, BasicObject] irb(main):011:0> Note however that the inheritance order is reversed. There are a number of other ways to achieve what you want. The requirement does not seem to come up very frequently though. So maybe it's not an issue as big as you think. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/