views:

99

answers:

1

Executing the below code gives me the following exception on the last line:

InvalidOperationException: "unbound variable: value"

var rubyRuntime = Ruby.CreateRuntime();
rubyRuntime.UseFile("HandleMoveRequested.rb");
var engine = rubyRuntime.GetEngine("rb");
dynamic ruby = engine.Runtime.Globals;

var handler = ruby.HandleMoveRequested.@new();

dynamic msg = new ExpandoObject();
msg.x = 1;
msg.y = 2;

handler.handle(msg);

The contents of HandleMoveRequested.rb are:

class HandleMoveRequested
    def handle(msg)
        System::Console.WriteLine msg.x
        System::Console.WriteLine msg.y
    end
end

Basically I just want to be able to pass a fully dynamic object into that Ruby object's "handle" method and have it be able to access the "x" and "y" properties on that object. Am I barking up the wrong tree?

+1  A: 

I tested your code (as-is) after building the latest from source: http://github.com/ironruby/ironruby

Please try this. I'd imagine the fix will be included in the next RC Build (RC3?) and later.
When you build from source, make sure you build the "V4 Release" build using Ruby4.sln

Edit: Tested myself, this works without issue in latest

Kevin Radcliffe