Class: LegacyMigrations::Operation
- Inherits:
-
Object
- Object
- LegacyMigrations::Operation
- Defined in:
- lib/legacy_migrations/status_report.rb
Instance Attribute Summary collapse
-
#destination ⇒ Object
Returns the value of attribute destination.
-
#inserts ⇒ Object
Returns the value of attribute inserts.
-
#sequence ⇒ Object
Returns the value of attribute sequence.
-
#source ⇒ Object
Returns the value of attribute source.
-
#source_type ⇒ Object
Returns the value of attribute source_type.
-
#type ⇒ Object
Returns the value of attribute type.
-
#updates ⇒ Object
Returns the value of attribute updates.
-
#validation_errors ⇒ Object
Returns the value of attribute validation_errors.
Instance Method Summary collapse
- #add_validation_error(new_record, from_record) ⇒ Object
- #description ⇒ Object
-
#initialize(properties) ⇒ Operation
constructor
A new instance of Operation.
- #record_insert(new_record) ⇒ Object
- #record_update(updated_record) ⇒ Object
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
#destination ⇒ Object
Returns the value of attribute destination.
56 57 58 |
# File 'lib/legacy_migrations/status_report.rb', line 56 def destination @destination end |
#inserts ⇒ Object
Returns the value of attribute inserts.
56 57 58 |
# File 'lib/legacy_migrations/status_report.rb', line 56 def inserts @inserts end |
#sequence ⇒ Object
Returns the value of attribute sequence.
56 57 58 |
# File 'lib/legacy_migrations/status_report.rb', line 56 def sequence @sequence end |
#source ⇒ Object
Returns the value of attribute source.
56 57 58 |
# File 'lib/legacy_migrations/status_report.rb', line 56 def source @source end |
#source_type ⇒ Object
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 |
#type ⇒ Object
Returns the value of attribute type.
56 57 58 |
# File 'lib/legacy_migrations/status_report.rb', line 56 def type @type end |
#updates ⇒ Object
Returns the value of attribute updates.
56 57 58 |
# File 'lib/legacy_migrations/status_report.rb', line 56 def updates @updates end |
#validation_errors ⇒ Object
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 |
#description ⇒ Object
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 |