Class: Planter::RecordAttributes
- Inherits:
-
Object
- Object
- Planter::RecordAttributes
- Defined in:
- lib/planter/record_attributes.rb
Overview
Prepares seed records for adapter persistence.
Instance Method Summary collapse
-
#initialize(context:, adapter:, transformations_provider:) ⇒ RecordAttributes
constructor
Create a record attribute preparer.
-
#prepare(record, parent_id: nil) ⇒ Array<Hash, Hash>
Prepare lookup and create attributes for adapter persistence.
Constructor Details
#initialize(context:, adapter:, transformations_provider:) ⇒ RecordAttributes
Create a record attribute preparer.
16 17 18 19 20 21 |
# 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 |
Instance Method Details
#prepare(record, parent_id: nil) ⇒ Array<Hash, Hash>
Prepare lookup and create attributes for adapter persistence.
31 32 33 34 35 36 |
# 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 |