Sha256: 3660e2dd2534d1adae4b5b7a4530efe4a95f6ceaebb20d67cee6e9e14399b85a

Contents?: true

Size: 1.15 KB

Versions: 80

Compression:

Stored size: 1.15 KB

Contents

module Cul::Hydra::Solrizer
class Extractor < ::Solrizer::Extractor
  # 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
  # @param [Hash] solr_doc
  # @param [String] field_name
  # @param [String] field_value
  # @param [boolean] unique
  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 Methods
  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
end
end

Version data entries

80 entries across 80 versions & 2 rubygems

Version Path
cul_hydra-1.11.2 lib/cul_hydra/solrizer/extractor.rb
cul_hydra-1.11.1 lib/cul_hydra/solrizer/extractor.rb
cul_hydra-1.11.0 lib/cul_hydra/solrizer/extractor.rb
cul_hydra-1.10.0 lib/cul_hydra/solrizer/extractor.rb
cul_hydra-1.9.6 lib/cul_hydra/solrizer/extractor.rb
cul_hydra-1.9.5 lib/cul_hydra/solrizer/extractor.rb
cul_hydra-1.9.4 lib/cul_hydra/solrizer/extractor.rb
cul_hydra-1.9.3 lib/cul_hydra/solrizer/extractor.rb
cul_hydra-1.9.2 lib/cul_hydra/solrizer/extractor.rb
cul_hydra-1.9.1 lib/cul_hydra/solrizer/extractor.rb
cul_hydra-1.9.0 lib/cul_hydra/solrizer/extractor.rb
cul_hydra-1.8.0 lib/cul_hydra/solrizer/extractor.rb
cul_hydra-1.7.6 lib/cul_hydra/solrizer/extractor.rb
cul_hydra-1.7.5 lib/cul_hydra/solrizer/extractor.rb
cul_hydra-1.7.4 lib/cul_hydra/solrizer/extractor.rb
cul_hydra-1.7.3 lib/cul_hydra/solrizer/extractor.rb
cul_hydra-1.7.2 lib/cul_hydra/solrizer/extractor.rb
cul_hydra-1.7.1 lib/cul_hydra/solrizer/extractor.rb
cul_hydra-1.7.0 lib/cul_hydra/solrizer/extractor.rb
cul_hydra-1.6.4 lib/cul_hydra/solrizer/extractor.rb