Class: LegacyMigrations::StatusReport

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/legacy_migrations/status_report.rb

Overview

The StatusReport is returned from each transfer_from and update_from function. Its purpose is to keep track of all the operations you’ve done so far, and to help you log information about them after they are complete.

Each status report has a many operations (one for each transfer or update)

Each Operation has a source, destination, type (transfer or update), inserts (array of records inserted), updates (array of records updated), validation errors, sequence and source type.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#operationsObject (readonly)

Returns the value of attribute operations.



16
17
18
# File 'lib/legacy_migrations/status_report.rb', line 16

def operations
  @operations
end

#sequenceObject (readonly)

Returns the value of attribute sequence.



16
17
18
# File 'lib/legacy_migrations/status_report.rb', line 16

def sequence
  @sequence
end

Instance Method Details

#add_operation(args) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/legacy_migrations/status_report.rb', line 18

def add_operation(args)
  @sequence ? @sequence += 1 : @sequence = 1
  @operations ||= []
  operation = Operation.new(args.merge({:sequence => @sequence}))
  @operations << operation
  operation
end

#operation_with(*args) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/legacy_migrations/status_report.rb', line 26

def operation_with(*args)
  @operations ||= []
  @operations.select do |operation|
    result = true
    args.last.each do |property, value|
      result = false unless operation.send(property) == value
    end
    result
  end[0]
end