lyrasis / aspace-client-tasks

Collection of thor tasks for processing data and interacting with the ASpace API
3 stars 1 forks source link

add `common:objects:attach_resources` #52

Closed eightBitter closed 1 year ago

eightBitter commented 1 year ago
desc "attach_resources DATA, FIELD", "attach resource ref to object by matching values from the given field. assumes DATA is an array of hashes, FIELD is a string"
    def attach_resources(data,field)
      index = execute "common:objects:make_index_resources"
      data.each do |record|
        # record[field].each {|entity| subjects_refs << index[entity]}
        record["resource__ref"] = index[record[field]]
      end

      data
    end