From: "Iñaki Baz Castillo" Date: 2008-04-30T08:03:25+09:00 Subject: Where and how is defined "attr_accessor"? Hi, I've done some custom "field_accessor" (similar to "attr_accessor" but with some neccessary difference). It works perfectly if I defined "field_accessor" in the same class: class Header def self.field_accessor(name) module_eval %{ def #{name}() .... end } end end class From < Header field_accessor :user, :domain end But I'd like to have field_accessor definition out of "Header" class, maybe in a module but don't get it working. If I do: module FieldAccessor module_eval %{ def #{name}() .... end } end class From include FieldAccessor field_accessor :user, :domain end Then I get: NoMethodError: undefined method `field_accessor' for From:Class Later I've tryed with the following and it seems to work: module FieldAccessor module_eval %{ def #{name}() .... end } # It also works with "class_eval". end class From extend FieldAccessor field_accessor :user, :domain end So, while I was writting this mail I found the solution, but would like to know if it's the correct way. Thanks a lot. -- Iñaki Baz Castillo