Class: CDMBL::BatchDeleter

Inherits:
Object
  • Object
show all
Defined in:
lib/cdmbl/batch_deleter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prefix: '', start: 0, batch_size: 10, oai_client: :missing_oai_client, solr_client: :missing_solr_client, oai_deletables_klass: OaiDeletables) ⇒ BatchDeleter

Returns a new instance of BatchDeleter.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/cdmbl/batch_deleter.rb', line 9

def initialize(prefix: '',
               start: 0,
               batch_size: 10,
               oai_client: :missing_oai_client,
               solr_client: :missing_solr_client,
               oai_deletables_klass: OaiDeletables)
  @prefix               = prefix
  @start                = start
  @batch_size           = batch_size
  @oai_client           = oai_client
  @solr_client          = solr_client
  @oai_deletables_klass = oai_deletables_klass
end

Instance Attribute Details

#batch_sizeObject (readonly)

Returns the value of attribute batch_size.



3
4
5
# File 'lib/cdmbl/batch_deleter.rb', line 3

def batch_size
  @batch_size
end

#oai_clientObject (readonly)

Returns the value of attribute oai_client.



3
4
5
# File 'lib/cdmbl/batch_deleter.rb', line 3

def oai_client
  @oai_client
end

#oai_deletables_klassObject (readonly)

Returns the value of attribute oai_deletables_klass.



3
4
5
# File 'lib/cdmbl/batch_deleter.rb', line 3

def oai_deletables_klass
  @oai_deletables_klass
end

#prefixObject (readonly)

Returns the value of attribute prefix.



3
4
5
# File 'lib/cdmbl/batch_deleter.rb', line 3

def prefix
  @prefix
end

#solr_clientObject (readonly)

Returns the value of attribute solr_client.



3
4
5
# File 'lib/cdmbl/batch_deleter.rb', line 3

def solr_client
  @solr_client
end

#startObject (readonly)

Returns the value of attribute start.



3
4
5
# File 'lib/cdmbl/batch_deleter.rb', line 3

def start
  @start
end

Instance Method Details

#deletablesObject



31
32
33
34
35
# File 'lib/cdmbl/batch_deleter.rb', line 31

def deletables
  @deletables ||= oai_deletables_klass.new(identifiers: ids,
                                           oai_client: oai_client,
                                           prefix: prefix).deletables
end

#delete!Object



23
24
25
# File 'lib/cdmbl/batch_deleter.rb', line 23

def delete!
  solr_client.delete deletables
end

#last_batch?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/cdmbl/batch_deleter.rb', line 27

def last_batch?
  start + batch_size >= num_found
end