Class: Stash::Harvester::HarvestedRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/stash/harvester/harvested_record.rb

Overview

Abstract superclass of protocol-specific records. Implementations should override #content to extract the record content, and may add other protocol-specific attributes as needed.

Direct Known Subclasses

OAIPMH::OAIRecord, Resync::ResyncRecord

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier:, timestamp:, deleted: false) ⇒ HarvestedRecord

Returns a new instance of HarvestedRecord.


20
21
22
23
24
# File 'lib/stash/harvester/harvested_record.rb', line 20

def initialize(identifier:, timestamp:, deleted: false)
  @identifier = identifier
  @timestamp = timestamp
  @deleted = deleted
end

Instance Attribute Details

#identifierString (readonly)

Returns a protocol-specific unique identifier for the record.

Returns:

  • (String)

    a protocol-specific unique identifier for the record.


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/stash/harvester/harvested_record.rb', line 14

class HarvestedRecord

  attr_reader :identifier
  attr_reader :timestamp
  attr_reader :deleted

  def initialize(identifier:, timestamp:, deleted: false)
    @identifier = identifier
    @timestamp = timestamp
    @deleted = deleted
  end

  # Implementations should override this method to extract the content
  # of the record.
  #
  # @return [String, nil] the content of the record, or +nil+ if the record
  #   has been deleted or the content is otherwise inaccessible.
  def content
    fail "#{self.class} should override #content to fetch the record content, but it doesn't"
  end

  # Visibility modifiers

  private :deleted
  alias_method :deleted?, :deleted
  public :deleted?

end

#timestampTime (readonly)

Returns a timestamp for the record, ideally its time of last modification.

Returns:

  • (Time)

    a timestamp for the record, ideally its time of last modification.


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/stash/harvester/harvested_record.rb', line 14

class HarvestedRecord

  attr_reader :identifier
  attr_reader :timestamp
  attr_reader :deleted

  def initialize(identifier:, timestamp:, deleted: false)
    @identifier = identifier
    @timestamp = timestamp
    @deleted = deleted
  end

  # Implementations should override this method to extract the content
  # of the record.
  #
  # @return [String, nil] the content of the record, or +nil+ if the record
  #   has been deleted or the content is otherwise inaccessible.
  def content
    fail "#{self.class} should override #content to fetch the record content, but it doesn't"
  end

  # Visibility modifiers

  private :deleted
  alias_method :deleted?, :deleted
  public :deleted?

end

Instance Method Details

#contentString?

Implementations should override this method to extract the content of the record.

Returns:

  • (String, nil)

    the content of the record, or nil if the record has been deleted or the content is otherwise inaccessible.


31
32
33
# File 'lib/stash/harvester/harvested_record.rb', line 31

def content
  fail "#{self.class} should override #content to fetch the record content, but it doesn't"
end