def self.define_annotated_attribute(base, attr_method_name)
base.module_eval do
define_method(attr_method_name) do |*args|
args.flatten!
harg={}; while args.last.is_a?(Hash)
harg.update(args.pop)
end
raise ArgumentError if args.empty? and harg.empty?
if args.empty?
harg.each { |a,h| __send__(attr_method_name,a,h) }
else
klass = harg[:class] = args.pop if args.last.is_a?(Class)
super(*args)
args.each{|a| ann(a.to_sym,harg)}
instance_attributes!.concat(args)
if respond_to?(:attr_callback)
attr_callback(self, args, harg)
end
return args
end
end
end
end