Class: Krikri::Harvesters::HarvestBehavior

Inherits:
Object
  • Object
show all
Defined in:
lib/krikri/harvesters/harvest_behavior.rb

Overview

Defines an interface for handling records during the harvest process. Subclasses specify behavior by implementing ‘#process_record`.

Behaviors should be implemented idempotently so they can be safely retried on errors.

Examples:

behavior = MyHarvestBehavior.new(record, activity_uri)
behavior.process_record
MyHarvestBehavior.process_record(record, activity_uri)

See Also:

  • Krirki::Harvester#run

Direct Known Subclasses

BasicSaveBehavior

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record, activity_uri) ⇒ HarvestBehavior

Returns a new instance of HarvestBehavior.



24
25
26
27
# File 'lib/krikri/harvesters/harvest_behavior.rb', line 24

def initialize(record, activity_uri)
  @record = record
  @activity_uri = activity_uri
end

Instance Attribute Details

#activity_uriObject (readonly)

a URI identifying the activity responsible for invoking the behavior



22
23
24
# File 'lib/krikri/harvesters/harvest_behavior.rb', line 22

def activity_uri
  @activity_uri
end

#recordObject (readonly)

Returns the value of attribute record.



22
# File 'lib/krikri/harvesters/harvest_behavior.rb', line 22

attr_reader :activity_uri, :record

Class Method Details

.process_record(record, activity_uri) ⇒ Object

Creates a new instance of this behavior with the given arguments and calls ‘#process_record`.

Parameters:

  • activity_uri
  • record

See Also:

  • self#activity_uri for parameter usage


36
37
38
# File 'lib/krikri/harvesters/harvest_behavior.rb', line 36

def self.process_record(record, activity_uri)
  new(record, activity_uri).process_record
end