Rbs weird behaviour on modules
-
Today I ran into this weird behaviour when scrambling my scripts into an rbs.
Lets say I have the folowing script:
module MyModule1 def self.load_second_script Sketchup;;require 'second_script' end#def end#module
in seconds_script.rb(s) i have:
module MyModule1 module MyModule2 end#module end#module
next, I do:
MyModule1.load_second_script
While testing with rb, this eventually gives
MyModule1;;MyModule2
as a valid module.
With rbs this results inMyModule1;;MyModule1;;MyModule2
Has anyone noticed this before?
Regards
-
@sr20vet said:
Has anyone noticed this before?
YES. ThomThom first noticed this, and has filed a bug report.
The error is within the
Sketchup::require()
method.To workaround, you will need to force the evaluation to occur within the
TOPLEVEL_BINDING
, thus:module MyModule1 def self.load_second_script eval("Sketchup;;require('second_script')",TOPLEVEL_BINDING,'second_script.rbs',1) end#def end#module
-
It also happens with
SketchupExtension
classes - where you cannot bypass theSketchup::require
call and I had to create a proxy .rb file to load the actual .rbs file. -
Ok, thanks for the workaround. You should expect that no mather you use rb's or rbs's, they behave the same way...
Advertisement