opal / opal-rails

Bringing Ruby to Rails · Rails bindings for Opal

Home Page:http://opalrb.com/#getting-started-rails

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

require executes module code

joostliketoast opened this issue · comments

I Noticed that when I require a module that it already executes the code inside it

module LittleHelper
  puts 'this is inside a module'
end
require 'little_helper'

class ExampleClass
end

I wouldn't expect a message but it already displays the puts, even though I didn't do a include in the class yet.

This is the expected on Ruby. When you require the file, the content gets read and "executed".

You have the puts inside the module, so it will get executed as soon as the module get declared. If you don't want it, you have to wrap it on a method.