-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I think the OP wanted class level attribute accessor, not instance level accessors. You showed how-to do instance level accessors:

  zdennis@lima:~$ irb
  irb(main):001:0> class A ; attr_accessor :foo ; end
  => nil
  irb(main):002:0> a = A.new
  => #<A:0xb7cdc8a8>
  irb(main):003:0> a.foo = 5
  => 5
  irb(main):004:0> a.foo
  => 5

but using mixins:

  irb(main):007:0> module M ; attr_accessor :foo ; end
  => nil
  irb(main):008:0> class B ; include M; end
  => B
  irb(main):009:0> b = B.new
  => #<B:0xb7cb20a4>
  irb(main):010:0> b.foo = 5
  => 5
  irb(main):011:0> b.foo
  => 5

I think OP wants the equivalent of:

  irb(main):012:0> class C ; class << self ; attr_accessor :foo ; end ; end
  => nil
  irb(main):013:0> C.foo = 5
  => 5
  irb(main):014:0> C.foo
  => 5

But with using mixins. The OP should just open up the instance of the class and include the module there. For example:

  irb(main):015:0> class D
  irb(main):016:1>   class << self
  irb(main):017:2>     include M
  irb(main):018:2>   end
  irb(main):019:1> end
  => #<Class:D>
  irb(main):020:0> D.foo = 99
  => 99
  irb(main):021:0> D.foo
  => 99

Zach



Farrel Lifson wrote:
> Worked pretty much how I expected it to:
> 
> 
>>>module TestModule
>>>  attr_accessor :attribute
>>>end
> 
> => nil
> 
>>>class TestClass
>>>  include TestModule
>>>end
> 
> => TestClass
> 
>>>tc = TestClass.new
> 
> => #<TestClass:0x2dc17c8>
> 
>>>tc.attribute = "Hello, world"
> 
> => "Hello, world"
> 
>>>puts tc.attribute
> 
> Hello, world
> => nil
> 
> Farrel
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFEOkNJMyx0fW1d8G0RAvzeAKCCzOvJoBDK/zHyDeI9uPdBd3I4RgCfWsIU
l9QTe4RbggocfasjnJQ4tw8=
=Sv/o
-----END PGP SIGNATURE-----