Class: Skala::PrimoAdapter::Search::ResultTransformation::DocTransformation

Inherits:
Transformator::Transformation
  • Object
show all
Defined in:
lib/skala/primo_adapter/search/result_transformation/doc_transformation.rb

Defined Under Namespace

Classes: SetCreator, SetDescription, SetEdition, SetFulltextAvailable, SetId, SetIdentifier, SetIsPartOf, SetLanguage, SetMetadata, SetOpenurl, SetPublisher, SetSource, SetSubject, SetTitle, SetYearOfPublication

Instance Method Summary collapse

Instance Method Details

#call(source, options = {}) ⇒ Object



9
10
11
12
# File 'lib/skala/primo_adapter/search/result_transformation/doc_transformation.rb', line 9

def call(source, options = {})
  options[:target] ||= Skala::Adapter::Search::Result::Hit.new(record: {})
  super(source, options)
end

#read_source_values(xpath, split: nil) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/skala/primo_adapter/search/result_transformation/doc_transformation.rb', line 35

def read_source_values(xpath, split: nil)
  source.xpath(xpath).map do |e|
    if split
      e.content.try do |c|
        c.split(split).map(&:strip)
      end
    else
      e.content
    end
  end.flatten.compact
end