Files
Yukihiro "Matz" Matsumoto 945410af3e mruby-toplevel-ext: add comprehensive call-seq documentation for toplevel include
Added complete call-seq documentation for the toplevel include method in
mrblib/toplevel.rb (1 method):

- include: enables module inclusion at the toplevel scope, delegates to
  Object.include to make module methods available to all objects globally,
  provides convenient syntax for extending the global namespace with
  module functionality

Co-authored-by: Atlassian Rovo Dev
2025-08-14 10:52:47 +09:00
..
2021-03-01 10:06:17 +10:00
2025-06-10 11:28:18 +09:00

mruby-toplevel-ext

mruby-toplevel-ext is a gem that modifies the toplevel in mruby by making the include method private. This means modules must be included directly into Object (e.g., Object.include MyModule) rather than at the toplevel.

Usage

After installing this gem, the include method at the toplevel (main) becomes private. This is the primary change provided by this gem.

Consider the following example:

module MyModule
  def my_method
    puts "Hello from MyModule!"
  end
end

# This will result in a NoMethodError because include is private:
# include MyModule
# my_method

# Instead, you must include the module directly into Object:
Object.include MyModule
my_method
# => Hello from MyModule!

This encourages a more explicit way of extending the global object space.

License

The gem is available as open source under the terms of the MIT License.