class A attr_accessor :x end a = A.new a.respond_to? :x # => true a.respond_to? :x= # => true a.respond_to? :y # => false