app/models/maestrano/connector/rails/concerns/entity.rb in maestrano-connector-rails-1.0.2 vs app/models/maestrano/connector/rails/concerns/entity.rb in maestrano-connector-rails-1.0.3

- old
+ new

@@ -237,11 +237,12 @@ def push_entities_to_external_to(mapped_connec_entities_with_idmaps, external_entity_name) return unless self.class.can_write_external? Maestrano::Connector::Rails::ConnectorLogger.log('info', @organization, "Sending Connec! #{self.class.connec_entity_name.pluralize} to #{Maestrano::Connector::Rails::External.external_name} #{external_entity_name.pluralize}") ids_to_send_to_connec = mapped_connec_entities_with_idmaps.map{ |mapped_connec_entity_with_idmap| - push_entity_to_external(mapped_connec_entity_with_idmap, external_entity_name) + idmap = push_entity_to_external(mapped_connec_entity_with_idmap, external_entity_name) + idmap ? {idmap: idmap} : nil }.compact unless ids_to_send_to_connec.empty? # Send the external ids to connec if it was a creation proc = lambda{|id| batch_op('put', {id: [Maestrano::Connector::Rails::ConnecHelper.id_hash(id[:idmap].external_id, @organization)]}, id[:idmap].connec_id, self.class.normalize_connec_entity_name(self.class.connec_entity_name)) } @@ -258,21 +259,21 @@ # Create and return id to send to connec! if idmap.external_id.blank? connec_id = idmap.connec_id external_id = create_external_entity(mapped_connec_entity, external_entity_name) idmap.update(external_id: external_id, last_push_to_external: Time.now, message: nil) - return {idmap: idmap} + return idmap # Update else return unless self.class.can_update_external? update_external_entity(mapped_connec_entity, idmap.external_id, external_entity_name) # Return the id to send it to connec! if the first push of a singleton if self.class.singleton? && idmap.last_push_to_external.nil? connec_id = mapped_connec_entity_with_idmap[:idmap].connec_id idmap.update(last_push_to_external: Time.now, message: nil) - return {idmap: idmap} + return idmap else idmap.update(last_push_to_external: Time.now, message: nil) end end \ No newline at end of file