method
respond_to?
respond_to?(name, include_private = false)
public
A Person object with a name attribute can ask person.respond_to?(:name), person.respond_to?(:name=), and person.respond_to?(:name?) which will all return true. It also defines the attribute methods if they have not been generated.
class Person < ActiveRecord::Base end person = Person.new person.respond_to(:name) # => true person.respond_to(:name=) # => true person.respond_to(:name?) # => true person.respond_to('age') # => true person.respond_to('age=') # => true person.respond_to('age?') # => true person.respond_to(:nothing) # => false