class Foo
 def hash
  @str.hash
 end
 def eql?(other)
  @str == other.str
 end
end
みたいな