Class: MigrationRecord

Inherits:
ApplicationRecord show all
Defined in:
app/models/migration_record.rb

Instance Method Summary collapse

Instance Method Details

#display_nameObject

Instance methods



47
48
49
# File 'app/models/migration_record.rb', line 47

def display_name
  "#{migrated_model_name} #{record_identifier}"
end

#record_changesObject

Custom getter for record_changes



24
25
26
27
28
29
30
31
32
33
# File 'app/models/migration_record.rb', line 24

def record_changes
  value = read_attribute(:record_changes)
  return {} if value.blank?
  return value if value.is_a?(Hash)

  JSON.parse(value)
rescue JSON::ParserError => e
  Rails.logger.error "Failed to parse record_changes for MigrationRecord #{id}: #{e.message}"
  {}
end

#record_changes=(value) ⇒ Object

Custom setter for record_changes



36
37
38
39
40
41
42
43
44
# File 'app/models/migration_record.rb', line 36

def record_changes=(value)
  if value.is_a?(String)
    write_attribute(:record_changes, value)
  elsif value.is_a?(Hash)
    write_attribute(:record_changes, value.to_json)
  else
    write_attribute(:record_changes, {}.to_json)
  end
end

#success?Boolean

Returns:



51
52
53
# File 'app/models/migration_record.rb', line 51

def success?
  !failed?
end