class Planter::RecordAttributes
Prepares seed records for adapter persistence.
Public Class Methods
Source
# File lib/planter/record_attributes.rb, line 16 def initialize(context:, adapter:, transformations_provider:) @context = context @adapter = adapter @transformations_provider = transformations_provider @warned_non_column_lookup_attributes = [] end
Create a record attribute preparer.
@param [Planter::SeedContext] context seeder configuration
@param [Object] adapter configured persistence adapter
@param [#call] transformations_provider returns value transformations by
field
Public Instance Methods
Source
# File lib/planter/record_attributes.rb, line 31 def prepare(record, parent_id: nil) lookup_attributes, create_attributes = split_record(apply_transformations(record)) lookup_attributes = lookup_attributes.merge(foreign_key => parent_id) if parent_id filter_lookup_attributes(lookup_attributes, create_attributes) end
Prepare lookup and create attributes for adapter persistence.
@param [Hash] record seed record attributes
@param [Object, nil] parent_id parent record id
@return [Array<Hash, Hash>]