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#modulein seconds_script.rb(s) i have:
module MyModule1 module MyModule2 end#module end#modulenext, I do:
MyModule1.load_second_scriptWhile testing with rb, this eventually gives
MyModule1;;MyModule2as a valid module.
With rbs this results inMyModule1;;MyModule1;;MyModule2Has 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
SketchupExtensionclasses - where you cannot bypass theSketchup::requirecall 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...
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement