Class: Traject::Indexer::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/traject/indexer.rb

Overview

Represents the context of a specific record being indexed, passed to indexing logic blocks

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash_init = {}) ⇒ Context

Returns a new instance of Context.



478
479
480
481
482
483
484
485
486
487
488
489
# File 'lib/traject/indexer.rb', line 478

def initialize(hash_init = {})
  # TODO, argument checking for required args?

  self.clipboard   = {}
  self.output_hash = {}

  hash_init.each_pair do |key, value|
    self.send("#{key}=", value)
  end
  
  @skip = false
end

Instance Attribute Details

#clipboardObject

Returns the value of attribute clipboard.



491
492
493
# File 'lib/traject/indexer.rb', line 491

def clipboard
  @clipboard
end

#field_nameObject

Returns the value of attribute field_name.



492
493
494
# File 'lib/traject/indexer.rb', line 492

def field_name
  @field_name
end

#output_hashObject

Returns the value of attribute output_hash.



491
492
493
# File 'lib/traject/indexer.rb', line 491

def output_hash
  @output_hash
end

#positionObject

1-based position in stream of processed records.



494
495
496
# File 'lib/traject/indexer.rb', line 494

def position
  @position
end

#settingsObject

Returns the value of attribute settings.



492
493
494
# File 'lib/traject/indexer.rb', line 492

def settings
  @settings
end

#skipmessageObject

Should we be skipping this record?



497
498
499
# File 'lib/traject/indexer.rb', line 497

def skipmessage
  @skipmessage
end

#source_recordObject

Returns the value of attribute source_record.



492
493
494
# File 'lib/traject/indexer.rb', line 492

def source_record
  @source_record
end

Instance Method Details

#skip!(msg = '(no message given)') ⇒ Object

Set the fact that this record should be skipped, with an optional message



501
502
503
504
# File 'lib/traject/indexer.rb', line 501

def skip!(msg = '(no message given)')
  @skipmessage = msg
  @skip = true
end

#skip?Boolean

Should we skip this record?

Returns:

  • (Boolean)


507
508
509
# File 'lib/traject/indexer.rb', line 507

def skip?
  @skip
end