Re: Nesting Includes



On 11/15/05, listrecv@xxxxxxxxx <listrecv@xxxxxxxxx> wrote:
> Hi. I'd like to include one module, which would include other modules
> into my namespace. Is this doable?
>
> Doing this:
> ----file1.rb
> module AAA
> include bbb
> end
>
> ----file2.rb
> include AAA
>
> does not seem to include bbb. Is there anyway to do this, or do I need
> to add the include explicilty to file2 as well?
>
Hi, you need to require the files you want:

----bbb.rb
module BBB
def bbb
puts "bbb"
end
end

----aaa.rb
require 'bbb'

module AAA
include BBB
end

---- test-nested-includes.rb
require 'aaa'
include AAA
bbb

---- OUTPUT
bbb

Regards,

Sean


.



Relevant Pages