Class: Arclight::Parents

Inherits:
Object
  • Object
show all
Defined in:
app/models/arclight/parents.rb

Overview

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ids:, legacy_ids:, labels:, eadid:, levels:) ⇒ Parents

Returns a new instance of Parents.



10
11
12
13
14
15
16
# File 'app/models/arclight/parents.rb', line 10

def initialize(ids:, legacy_ids:, labels:, eadid:, levels:)
  @ids = ids
  @legacy_ids = legacy_ids
  @labels = labels
  @eadid = eadid
  @levels = levels
end

Instance Attribute Details

#idsObject (readonly)

Returns the value of attribute ids.



8
9
10
# File 'app/models/arclight/parents.rb', line 8

def ids
  @ids
end

#labelsObject (readonly)

Returns the value of attribute labels.



8
9
10
# File 'app/models/arclight/parents.rb', line 8

def labels
  @labels
end

#legacy_idsObject (readonly)

Returns the value of attribute legacy_ids.



8
9
10
# File 'app/models/arclight/parents.rb', line 8

def legacy_ids
  @legacy_ids
end

#levelsObject (readonly)

Returns the value of attribute levels.



8
9
10
# File 'app/models/arclight/parents.rb', line 8

def levels
  @levels
end

Class Method Details

.from_solr_document(document) ⇒ Object

Parameters:



30
31
32
33
34
35
36
37
# File 'app/models/arclight/parents.rb', line 30

def self.from_solr_document(document)
  ids = document.parent_ids
  legacy_ids = document.legacy_parent_ids.map { |legacy_id| document.collection_id == legacy_id ? legacy_id : "#{document.collection_id}#{legacy_id}" }
  labels = document.parent_labels
  eadid = document.eadid
  levels = document.parent_levels
  new(ids: ids, legacy_ids: legacy_ids, labels: labels, eadid: eadid, levels: levels)
end

Instance Method Details

#as_parentsArray[Arclight::Parent]

Returns:



24
25
26
# File 'app/models/arclight/parents.rb', line 24

def as_parents
  (ids.presence || legacy_ids).map.with_index { |id, idx| Arclight::Parent.new(id: id, label: labels[idx], eadid: eadid, level: levels[idx]) }
end

#eadidObject



18
19
20
# File 'app/models/arclight/parents.rb', line 18

def eadid
  Arclight::NormalizedId.new(@eadid).to_s
end