Class: CDMDEXER::Transformer

Inherits:
Object
  • Object
show all
Defined in:
lib/cdmdexer/transformer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cdm_records: [], oai_endpoint: :MISSING_OAI_ENDPOINT, field_mappings: false, record_transformer: RecordTransformer, cache_klass: ::Rails, oai_request_klass: OaiRequest) ⇒ Transformer

Returns a new instance of Transformer.



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cdmdexer/transformer.rb', line 14

def initialize(cdm_records: [],
               oai_endpoint: :MISSING_OAI_ENDPOINT,
               field_mappings: false,
               record_transformer: RecordTransformer,
               cache_klass: ::Rails,
               oai_request_klass: OaiRequest)
  @cdm_records        = cdm_records
  @oai_endpoint       = oai_endpoint
  @field_mappings     = field_mappings ? field_mappings : default_field_mappings
  @record_transformer = record_transformer
  @cache_klass        = cache_klass
  @oai_request_klass  = oai_request_klass
end

Instance Attribute Details

#cache_klassObject (readonly)

Returns the value of attribute cache_klass.



7
8
9
# File 'lib/cdmdexer/transformer.rb', line 7

def cache_klass
  @cache_klass
end

#cdm_recordsObject (readonly)

Returns the value of attribute cdm_records.



7
8
9
# File 'lib/cdmdexer/transformer.rb', line 7

def cdm_records
  @cdm_records
end

#field_mappingsObject (readonly)

Returns the value of attribute field_mappings.



7
8
9
# File 'lib/cdmdexer/transformer.rb', line 7

def field_mappings
  @field_mappings
end

#oai_endpointObject (readonly)

Returns the value of attribute oai_endpoint.



7
8
9
# File 'lib/cdmdexer/transformer.rb', line 7

def oai_endpoint
  @oai_endpoint
end

#oai_request_klassObject (readonly)

Returns the value of attribute oai_request_klass.



7
8
9
# File 'lib/cdmdexer/transformer.rb', line 7

def oai_request_klass
  @oai_request_klass
end

#record_transformerObject (readonly)

Returns the value of attribute record_transformer.



7
8
9
# File 'lib/cdmdexer/transformer.rb', line 7

def record_transformer
  @record_transformer
end

Instance Method Details

#recordsObject



28
29
30
# File 'lib/cdmdexer/transformer.rb', line 28

def records
  cdm_records.map { |record| to_solr(record) }.compact
end