Class: CDMDEXER::Loader

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(records: [], deletable_ids: [], solr_client: CDMDEXER::DefaultSolr) ⇒ Loader

Returns a new instance of Loader.



6
7
8
9
10
11
12
# File 'lib/cdmdexer/loader.rb', line 6

def initialize(records: [],
               deletable_ids: [],
               solr_client: CDMDEXER::DefaultSolr)
  @solr_client   = solr_client
  @records       = records
  @deletable_ids = deletable_ids
end

Instance Attribute Details

#deletable_idsObject (readonly)

Returns the value of attribute deletable_ids.



4
5
6
# File 'lib/cdmdexer/loader.rb', line 4

def deletable_ids
  @deletable_ids
end

#recordsObject (readonly)

Returns the value of attribute records.



4
5
6
# File 'lib/cdmdexer/loader.rb', line 4

def records
  @records
end

#solr_clientObject (readonly)

Returns the value of attribute solr_client.



4
5
6
# File 'lib/cdmdexer/loader.rb', line 4

def solr_client
  @solr_client
end

Instance Method Details

#load!Object



14
15
16
17
# File 'lib/cdmdexer/loader.rb', line 14

def load!
  solr_client.delete deletable_ids unless deletable_ids.empty?
  solr_client.add records
end