Object#respond_to?メソッドを使う

class Hoge
  @foo
  attr_accessor :foo
end

a = Hoge.new
a.respond_to?("foo") #=> true
a.respond_to?("bar") #=> false