Ruby - Module Nested Inclusions

Introduction

You include can call load and require themselves.

For example, assume a.rb contains the following:

require 'b' 

and b.rb contains the following:

require 'c' 

and c.rb contains the following:

def example 
  puts "Hello!" 
end 

and d.rb contains the following:

require 'a' 
example 

When d.rb is then run,

Hello! 

d.rb includes a.rb with require, a.rb includes b.rb, and b.rb includes c.rb, meaning the example method is available to d.rb.

Related Topic