[Ironruby-core] scope.SetVariable weirdness with instance_eval

Ivan Porto Carrero ivan at flanders.co.nz
Thu Nov 19 13:21:22 EST 2009


Hi

Consider the following code:

public class Item
{
   public string Title  {
get;
 private set;
   }

   public Item(string title){ Title = title; }
}

var _engine = Ruby.CreateEngine();
var context = new Item("The greatest item ever");

var scope = _engine.CreateScope();
*scope.SetVariable("ctxt", item);*
_engine.ExecuteFile("path\to\file.rb", scope);

And the following ruby class:

class Testing

  def initialize(&b)
    instance_eval(&b)
  end

  def context(ctxt)
    @ctxt = ctxt
  end

  def print
    puts @ctxt.title
  end

end

Then this works when put at the bottom of the file:

*inserted = ctxt*
Testing.new do
  *context inserted*
  print
end

but this doesn't:

Testing.new do
  *context ctxt*
  print
end


That doesn't seem right or does it? so I've created an issue on codeplex
with this content, if this is the way it's supposed to work then I'll delete
the issue


---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz
Google Wave: portocarrero.ivan at googlewave.com
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20091119/630c9163/attachment.html>


More information about the Ironruby-core mailing list