Class: CollectionManagement

Inherits:
Sequel::Model
  • Object
show all
Defined in:
backend/app/model/collection_management.rb

Class Method Summary collapse

Class Method Details

.sequel_to_jsonmodel(objs, opts = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'backend/app/model/collection_management.rb', line 9

def self.sequel_to_jsonmodel(objs, opts = {})
  jsons = super

  jsons.zip(objs).each do |json, obj|
    parent_uri = if obj.resource_id
                   JSONModel(:resource).uri_for(obj.resource_id, :repo_id => active_repository)
                 elsif obj.digital_object_id
                   JSONModel(:digital_object).uri_for(obj.digital_object_id, :repo_id => active_repository)
                 elsif obj.accession_id
                   JSONModel(:accession).uri_for(obj.accession_id, :repo_id => active_repository)
                 end

    if parent_uri
      json['parent'] = {
        'ref' => parent_uri
      }
    end
  end

  jsons
end