module DatabaseTransform::SchemaTableRecordMapping

Public Instance Methods

memoize_transform(old_primary_key, result) click to toggle source

@api private

Called by TableTransform#run_transform
# File lib/database_transform/schema_table_record_mapping.rb, line 27
def memoize_transform(old_primary_key, result)
  @transformed ||= {}
  @transformed[old_primary_key] = result
end
transform(old_primary_key) click to toggle source

Obtains the result of transforming the record with the given primary key.

@param old_primary_key The primary key of the record to obtain the result for. @raise [ActiveRecord::RecordNotFound] When the primary has not been transformed, or the primary key does not exist. @return The new record after transformation.

# File lib/database_transform/schema_table_record_mapping.rb, line 7
def transform(old_primary_key)
  @transformed ||= {}
  unless @transformed.has_key?(old_primary_key)
    raise ActiveRecord::RecordNotFound.new("Key #{old_primary_key} in #{table_name}")
  end

  @transformed[old_primary_key]
end
transformed?(old_primary_key) click to toggle source

Checks if the given primary key has been transformed.

@param old_primary_key The primary key of the record to obtain the result for. @return [Boolean] True if the record has been transformed.

# File lib/database_transform/schema_table_record_mapping.rb, line 20
def transformed?(old_primary_key)
  @transformed ||= {}
  @transformed.has_key?(old_primary_key)
end