your solution does however work for the assignment accessor... in fact, you can do something like this:
class Foo attr_reader :bar def bar=(val) # do more stuff here for example @bar = val end end and then you can do the following in C#: var value = myObject.bar; myObject.bar = someOtherValue; for my specific scenario, i think i can actually get by with just overriding the assignment accessor but the thing i'm wondering is: is the current behavior actually a bug? and will this behavior be preserved in future releases? On Tue, Sep 7, 2010 at 11:13 AM, Davy Brion <ral...@davybrion.com> wrote: > if i do that, calling bar as a property like this: > > var value = myObject.bar; > > leads to 'value' being an instance of IronRuby.BuiltIns.RubyMethod, and not > the value that is in the @bar instance field > > which > > i'm using 1.1 btw, not sure how this would behave on 1.0 > > from looking at the IronRuby source code, it looks like i need to find a > way to change the RubyMemberInfo for a given accessor method to > RubyAttributeReaderInfo or RubyAttributeWriterInfo > > > On Tue, Sep 7, 2010 at 11:01 AM, Ivan Porto Carerro > <i...@flanders.co.nz>wrote: > >> You can just define them as attr_accessors and then implement the methods >> >> class Foo >> >> attr_accessor :bar, :baz >> >> def bar=(val) >> # do more stuff here for example >> @bar = val >> end >> >> def bar >> @bar >> end >> >> end >> >> On Tue, Sep 7, 2010 at 10:36 AM, Davy Brion <ral...@davybrion.com> wrote: >> >>> Hi all, >>> >>> IronRuby has a nice trick where attributes defined by attr_reader, >>> attr_accessor and attr_writer are usable as properties from C#... i was just >>> wondering: is it possible to use the same trick in our own ruby code? >>> >>> or can anyone just point me in the right direction as to where in the >>> IronRuby source code i could find where this is being done? >>> >>> I have accessor methods that really need to do something specific and >>> ideally, i'd like them be usable as properties in .NET since it leads to a >>> much nicer syntax in C# >>> >>> brs, >>> Davy >>> >>> _______________________________________________ >>> Ironruby-core mailing list >>> Ironruby-core@rubyforge.org >>> http://rubyforge.org/mailman/listinfo/ironruby-core >>> >>> >> >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core@rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core >> >> >
_______________________________________________ Ironruby-core mailing list Ironruby-core@rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core