module ActiveRecord::AttributeMethods
def respond_to?(name, include_private = false)
person.respond_to?('age?') # => true
person.respond_to?('age=') # => true
person.respond_to?('age') # => true
person.respond_to?(:name?) # => true
person.respond_to?(:name=) # => true
person.respond_to?(:name) # => true
person = Person.new
end
class Person < ActiveRecord::Base
not been generated.
which will all return +true+. It also defines the attribute methods if they have
person.respond_to?(:name=), and person.respond_to?(:name?)
A Person object with a name attribute can ask person.respond_to?(:name),
def respond_to?(name, include_private = false) return false unless super # If the result is true then check for the select case. # For queries selecting a subset of columns, return false for unselected columns. # We check defined?(@attributes) not to issue warnings if called on objects that # have been allocated but not yet initialized. if defined?(@attributes) if name = self.class.symbol_column_to_string(name.to_sym) return _has_attribute?(name) end end true end