Class: LegacyMigrations::Operation

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(properties) ⇒ Operation

Returns a new instance of Operation.



60
61
62
63
64
# File 'lib/legacy_migrations/status_report.rb', line 60

def initialize(properties)
  properties.each do |property, value|
    send("#{property.to_s}=", value) if respond_to? "#{property.to_s}="
  end
end

Instance Attribute Details

#destinationObject

Returns the value of attribute destination.



56
57
58
# File 'lib/legacy_migrations/status_report.rb', line 56

def destination
  @destination
end

#insertsObject

Returns the value of attribute inserts.



56
57
58
# File 'lib/legacy_migrations/status_report.rb', line 56

def inserts
  @inserts
end

#sequenceObject

Returns the value of attribute sequence.



56
57
58
# File 'lib/legacy_migrations/status_report.rb', line 56

def sequence
  @sequence
end

#sourceObject

Returns the value of attribute source.



56
57
58
# File 'lib/legacy_migrations/status_report.rb', line 56

def source
  @source
end

#source_typeObject

Returns the value of attribute source_type.



56
57
58
# File 'lib/legacy_migrations/status_report.rb', line 56

def source_type
  @source_type
end

#typeObject

Returns the value of attribute type.



56
57
58
# File 'lib/legacy_migrations/status_report.rb', line 56

def type
  @type
end

#updatesObject

Returns the value of attribute updates.



56
57
58
# File 'lib/legacy_migrations/status_report.rb', line 56

def updates
  @updates
end

#validation_errorsObject

Returns the value of attribute validation_errors.



56
57
58
# File 'lib/legacy_migrations/status_report.rb', line 56

def validation_errors
  @validation_errors
end

Instance Method Details

#add_validation_error(new_record, from_record) ⇒ Object



77
78
79
80
81
82
# File 'lib/legacy_migrations/status_report.rb', line 77

def add_validation_error(new_record, from_record)
  @validation_errors ||= []
  validation_error = ValidationError.new(new_record, from_record)
  @validation_errors << validation_error
  validation_error
end

#descriptionObject



84
85
86
87
88
89
90
91
# File 'lib/legacy_migrations/status_report.rb', line 84

def description
  inserts = @inserts.try(:size) || 0
  updates = @updates.try(:size) || 0
  insert_phrase = "#{inserts} #{inserts == 1 ? 'insert' : 'inserts'}"
  update_phrase = "#{updates} #{updates == 1 ? 'update' : 'updates'}"
  actions = [insert_phrase, update_phrase].join(' and ') << '.'
  "#{@type.capitalize} of data from #{@source.to_s.pluralize} to #{@destination.to_s.pluralize} resulted in #{actions}"
end

#record_insert(new_record) ⇒ Object



71
72
73
74
75
# File 'lib/legacy_migrations/status_report.rb', line 71

def record_insert(new_record)
  @inserts ||= []
  @inserts << new_record

end

#record_update(updated_record) ⇒ Object



66
67
68
69
# File 'lib/legacy_migrations/status_report.rb', line 66

def record_update(updated_record)
  @updates ||= []
  @updates << updated_record
end