Class: DBPurger::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/db-purger/executor.rb

Overview

DBPurger::Executor used to execute a purge plan with verification

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database, plan, options = {}) ⇒ Executor

Returns a new instance of Executor.



8
9
10
11
12
13
# File 'lib/db-purger/executor.rb', line 8

def initialize(database, plan, options = {})
  @database = database
  @plan = plan.is_a?(Plan) ? plan : load_plan(plan)
  setup_config(options)
  @error_io = $stderr
end

Instance Attribute Details

#error_io=(value) ⇒ Object (writeonly)

Sets the attribute error_io

Parameters:

  • value

    the value to set the attribute error_io to.



6
7
8
# File 'lib/db-purger/executor.rb', line 6

def error_io=(value)
  @error_io = value
end

Instance Method Details

#purge!(purge_value) ⇒ Object



15
16
17
18
19
# File 'lib/db-purger/executor.rb', line 15

def purge!(purge_value)
  raise('purge_value is nil') if purge_value.nil?

  @plan.purge!(@database, purge_value)
end

#verify!Object



21
22
23
24
25
26
# File 'lib/db-purger/executor.rb', line 21

def verify!
  return if plan_validator.valid?

  output_plan_errors
  raise('purge plan failed verification')
end