Replace #has_key? with #try(:has_key?)