Use #each instead of #each_pair

Using #each_pair assumes that the attributes are passed in as a hash.
Duplicate objects properly for the identity map