Class: CDMDEXER::CdmItem

Inherits:
Object
  • Object
show all
Defined in:
lib/cdmdexer/cdm_item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record: :MISSING_RECORD, cdm_endpoint: :MISSING_ENDPOINT, cdm_api_klass: CONTENTdmAPI::Item, cdm_notification_klass: CDMDEXER::CdmNotification) ⇒ CdmItem

Returns a new instance of CdmItem.



10
11
12
13
14
15
16
17
18
19
# File 'lib/cdmdexer/cdm_item.rb', line 10

def initialize(record: :MISSING_RECORD,
               cdm_endpoint: :MISSING_ENDPOINT,
               cdm_api_klass: CONTENTdmAPI::Item,
               cdm_notification_klass: CDMDEXER::CdmNotification)
  @record                 = record
  @collection, @id        = record['id'].split(':')
  @cdm_endpoint           = cdm_endpoint
  @cdm_api_klass          = cdm_api_klass
  @cdm_notification_klass = cdm_notification_klass
end

Instance Attribute Details

#cdm_api_klassObject (readonly)

Returns the value of attribute cdm_api_klass.



3
4
5
# File 'lib/cdmdexer/cdm_item.rb', line 3

def cdm_api_klass
  @cdm_api_klass
end

#cdm_endpointObject (readonly)

Returns the value of attribute cdm_endpoint.



3
4
5
# File 'lib/cdmdexer/cdm_item.rb', line 3

def cdm_endpoint
  @cdm_endpoint
end

#cdm_notification_klassObject (readonly)

Returns the value of attribute cdm_notification_klass.



3
4
5
# File 'lib/cdmdexer/cdm_item.rb', line 3

def cdm_notification_klass
  @cdm_notification_klass
end

#collectionObject (readonly)

Returns the value of attribute collection.



3
4
5
# File 'lib/cdmdexer/cdm_item.rb', line 3

def collection
  @collection
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/cdmdexer/cdm_item.rb', line 3

def id
  @id
end

#recordObject (readonly)

Returns the value of attribute record.



3
4
5
# File 'lib/cdmdexer/cdm_item.rb', line 3

def record
  @record
end

Instance Method Details

#pageObject



28
29
30
31
# File 'lib/cdmdexer/cdm_item.rb', line 28

def page
  primary_record.fetch('page', [])
                .each_with_index.map { |page, i| to_compound(page, i) }
end

#to_hObject



21
22
23
24
25
26
# File 'lib/cdmdexer/cdm_item.rb', line 21

def to_h
  # Preserve the record hash. It may contain compound data that has been
  # resubmitted here by the transformer_worker as it recurses through
  # compounds in order to extract their full metadata
  @to_h ||= record.merge()
end