[Ironruby-core] Why does attr_accessor create a property, but method is just a method?
briangenisio at gmail.com
Fri Jul 23 11:41:13 EDT 2010
It is a good idea, but I have tried this already, and it still fails. By
re-defining the method after attr_accessor, you blow away whatever magic
happens that causes it to be a property at interop time.
Unless... you are suggesting that this is how it SHOULD work.
I think either approach makes sense. A special interop class method is nice
because it is explicit. Having method redefinition do the job is nice
because it doesn't require a special class method :)
What does everyone else think?
If I get the time, I was planning on getting my hands in the code and trying
to implement it.
2010/7/23 Jörg W Mittag
<JoergWMittag+Ruby at googlemail.com<JoergWMittag%2BRuby at googlemail.com>
> Brian Genisio wrote:
> > Thinking on this further, if there were some sort of interop-specific
> > method... like attr_clr_property :foo, that caused any methods named foo
> > foo=(var) to be visible to .Net as properties, that would be sufficient.
> > Any thoughts on this?
> Alternative suggestion: make method redefinition work in this case,
> like this:
> var engine = IronRuby.Ruby.CreateEngine();
> var script = @"
> class Test
> attr_accessor :a, :m
> def m; @m end
> def m=(val) @m = val end
> def initialize; @a, @m = 'automatic', 'manual' end
> var testObject = engine.Execute(script);
> var automatic = testObject.a;
> var manual = testObject.m;
> Console.WriteLine(manual); // should print "manual"
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironruby-core