- unless hash.key? m[1]
- # use reflection to look up the appropriate class
- model = Kernel.const_get(m[0].capitalize)
- # get the element with that ID
- element = model.where(:id => m[1]).first
-
- # and check that it is OK to use.
- unless element && element.visible? && element.preconditions_ok?
- fail OSM::APIPreconditionFailedError.new("Relation with id #{id} cannot be saved due to #{m[0]} with id #{m[1]}")
- end
- hash[m[1]] = true
+ next if hash.key? m[1]
+
+ # use reflection to look up the appropriate class
+ model = Kernel.const_get(m[0].capitalize)
+ # get the element with that ID
+ element = model.where(:id => m[1]).first
+
+ # and check that it is OK to use.
+ unless element && element.visible? && element.preconditions_ok?
+ fail OSM::APIPreconditionFailedError.new("Relation with id #{id} cannot be saved due to #{m[0]} with id #{m[1]}")