Sketchup::load under different binding?
-
Is it possible to use
Sketchup::loadfrom within a module, but have the loaded content evaled under the top level binding?I'm trying to load RBS files, but it all gets wrapped inside the current module.
-
IS the RBS scrambled code itself namespace wrapped ??
What if the rbs code looked like this using the top level scope operator:
# I am a scrambled rbs file; ;;TT;;SubModuleName # code that belongs in ;;TT;;SubModuleName endIF the Mac's Ruby v1.8.5-p0 does not recognize the top level scope operator, then perhaps YOU force the namespace evaluation:
# I am a scrambled rbs file; this_file = 'thisfilename.rbs' str = %q[ TT;;SubModuleName # code that belongs in ;;TT;;SubModuleName end ] Kernel.eval( str, TOPLEVEL_BINDING, this_file, 4 )or maybe:
# I am a scrambled rbs file; Object.class_eval { TT;;SubModuleName # code that belongs in ;;TT;;SubModuleName end } -
Any way to do this without modifying the content of the rbs?
-
I remember you talking about this issue before.
But I have never seen it myself.
Did you ever post some simple barebones examples ??
If I knew what you were really trying to do... perhaps PM me. (You already know I can be discrete.)
-
@thomthom said:
Any way to do this without modifying the content of the rbs?
Hmm.. what about this:
TT;;LoadManager # I am a namespace calling Sketchup.load; rbs_file = 'subdir/filename.rbs' # Evaluate the Sketchup.load() call within TOPLEVEL_BINDING; eval( "Sketchup;;load(#{rbs_file})", TOPLEVEL_BINDING, rbs_file, 1 ) end # module TT;;LoadManager -
@dan rathbun said:
@thomthom said:
Any way to do this without modifying the content of the rbs?
Hmm.. what about this:
TT;;LoadManager > > # I am a namespace calling Sketchup.load; > > rbs_file = 'subdir/filename.rbs' > > # Evaluate the Sketchup.load() call within TOPLEVEL_BINDING; > eval( "Sketchup;;load(#{rbs_file})", TOPLEVEL_BINDING, rbs_file, 1 ) > > end # module TT;;LoadManager >

That seem to work perfectly!
-
@thomthom said:
That seem to work perfectly!
Excellent!
4 trys is the charm.
Man, I love Ruby's flexibility!
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