app/models/maestrano/connector/rails/concerns/connec_helper.rb in maestrano-connector-rails-2.3.2 vs app/models/maestrano/connector/rails/concerns/connec_helper.rb in maestrano-connector-rails-2.3.3

- old
+ new

@@ -117,10 +117,11 @@ field = entity[ref] # Unfold the id if array_of_refs.empty? && field return entity.delete(ref) if field.is_a?(String) # ~retro-compatibility to ease transition aroud Connec! idmaps rework. Should be removed eventually. + id_hash = field.find { |id| id[:provider] == organization.oauth_provider && id[:realm] == organization.oauth_uid } if id_hash entity[ref] = id_hash['id'] elsif field.find { |id| id[:provider] == 'connec' } # Should always be true as ids will always contain a connec id # We may enqueue a fetch on the endpoint of the missing association, followed by a re-fetch on this one. @@ -132,10 +133,11 @@ true # Follow embedment path else return true if field.blank? + case field when Array bool = true field.each do |f| bool &= unfold_references_helper(f, array_of_refs.dup, organization) @@ -149,10 +151,11 @@ # Transforms the references into an hash {record_references: [], id_references: []} # References can either be an array (only record references), or a hash def format_references(references) return {record_references: references, id_references: []} if references.is_a?(Array) + references[:record_references] ||= [] references[:id_references] ||= [] references end @@ -171,9 +174,10 @@ end # Recursive method for filtering connec entities def filter_connec_entity_for_id_refs_helper(entity_hash, tree) return if tree.empty? + entity_hash.slice!(*tree.keys) tree.each do |key, children| case entity_hash[key] when Array