From: 7stud -- Date: 2011-04-15T09:50:51+09:00 Subject: Re: What do you do when you need to attach data to an object instance? Aaron D. Gifford wrote in post #992887: > > Now another question. I noticed that if I don't include the > send(:public) bit up there, that the send(:attr_accessor) message > delivered to the anonymous module ends up creating private accessor > methods, not public. > > I find that puzzling: > Me too: module Mod attr_accessor :data def do_stuff end end p Mod.public_instance_methods.grep(/^d/) --output:-- [:data, :data=, :do_stuff] Test = Module.new Test.send(:attr_accessor, :data) Test.send(:define_method, :do_stuff, Proc.new {puts 'hi'}) p Test.public_instance_methods.grep(/^d/) p Test.private_instance_methods.grep(/^d/) --output:-- -- Posted via http://www.ruby-forum.com/.