def method_missing(method_id, *args, &block)
method_name = method_id.to_s
if column_for_attribute(method_name) or
((md = /\?$/.match(method_name)) and
column_for_attribute(query_method_name = md.pre_match) and
method_name = query_method_name)
define_read_methods if self.class.read_methods.empty? && self.class.generate_read_methods
md ? query_attribute(method_name) : read_attribute(method_name)
elsif self.class.primary_key.to_s == method_name
id
elsif (md = self.class.match_attribute_method?(method_name))
attribute_name, method_type = md.pre_match, md.to_s
if column_for_attribute(attribute_name)
__send__("attribute#{method_type}", attribute_name, *args, &block)
else
super
end
else
super
end
end