Class: Cul::Hydra::Solrizer::Extractor

Inherits:
Solrizer::Extractor
  • Object
show all
Defined in:
lib/cul_hydra/solrizer/extractor.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.insert_solr_field_value(solr_doc, field_name, field_value, unique = false) ⇒ Object

Insert field_value for field_name into solr_doc Handles inserting new values into a Hash while ensuring that you don’t destroy or overwrite any existing values in the hash. Ensures that field values are always appended to arrays within the values hash. Ensures that values are run through format_node_value Also ensures that values are unique if specified

Parameters:

  • solr_doc (Hash)
  • field_name (String)
  • field_value (String)
  • unique (boolean) (defaults to: false)


12
13
14
15
16
17
18
19
20
# File 'lib/cul_hydra/solrizer/extractor.rb', line 12

def self.insert_solr_field_value(solr_doc, field_name, field_value, unique=false)
  formatted_value = self.format_node_value(field_value)
  if solr_doc.has_key?(field_name)
    solr_doc[field_name] << formatted_value unless (unique and solr_doc[field_name].include? formatted_value)
  else
    solr_doc.merge!( {field_name => [formatted_value]} ) 
  end
  return solr_doc
end

Instance Method Details

#insert_solr_field_value(solr_doc, field_name, field_value, unique = false) ⇒ Object

Instance Methods



23
24
25
# File 'lib/cul_hydra/solrizer/extractor.rb', line 23

def insert_solr_field_value(solr_doc, field_name, field_value, unique=false)
  Cul::Hydra::Solrizer::Extractor.insert_solr_field_value(solr_doc, field_name, field_value, unique)
end