Require file without executing code?

Viewed 5762

Here I have two files:

file.rb

def method
  puts "This won't be outputted."
end

puts "This will be outputted."

main.rb

require "./file"

When running main.rb it will load all the code inside file.rb so I will get "This will be outputted." on the screen.

Is it possible to load a file without having it to run the code?

Cause I want to load all the methods (in modules and classes too) without having to execute code outside these scopes.

3 Answers
Related