Class: Planter::SeedContext
- Inherits:
-
Object
- Object
- Planter::SeedContext
- Defined in:
- lib/planter/seed_context.rb
Overview
Parameter object carrying normalized seeder configuration into adapters.
Instance Attribute Summary collapse
-
#csv_name ⇒ String
readonly
The CSV seed file name without an extension.
-
#erb_trim_mode ⇒ String?
readonly
The ERB trim mode used for CSV templates.
-
#number_of_records ⇒ Integer
readonly
How many times to create each data record.
-
#parent ⇒ String, ...
readonly
The adapter-defined parent relation.
-
#seed_method ⇒ Symbol?
readonly
The configured seeding method.
-
#table_name ⇒ String
readonly
The table being seeded.
-
#unique_columns ⇒ Array<Symbol>?
readonly
Columns used to look up existing records.
Instance Method Summary collapse
-
#initialize(table_name:, seed_method:, csv_name:, parent:, number_of_records:, unique_columns:, erb_trim_mode:) ⇒ SeedContext
constructor
Create a new seed context.
Constructor Details
#initialize(table_name:, seed_method:, csv_name:, parent:, number_of_records:, unique_columns:, erb_trim_mode:) ⇒ SeedContext
Create a new seed context.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/planter/seed_context.rb', line 65 def initialize( table_name:, seed_method:, csv_name:, parent:, number_of_records:, unique_columns:, erb_trim_mode: ) @table_name = table_name.to_s @seed_method = seed_method&.intern @csv_name = csv_name.to_s @parent = parent @number_of_records = number_of_records @unique_columns = unique_columns @erb_trim_mode = erb_trim_mode end |
Instance Attribute Details
#csv_name ⇒ String (readonly)
The CSV seed file name without an extension.
23 24 25 |
# File 'lib/planter/seed_context.rb', line 23 def csv_name @csv_name end |
#erb_trim_mode ⇒ String? (readonly)
The ERB trim mode used for CSV templates.
47 48 49 |
# File 'lib/planter/seed_context.rb', line 47 def erb_trim_mode @erb_trim_mode end |
#number_of_records ⇒ Integer (readonly)
How many times to create each data record.
35 36 37 |
# File 'lib/planter/seed_context.rb', line 35 def number_of_records @number_of_records end |
#parent ⇒ String, ... (readonly)
The adapter-defined parent relation.
29 30 31 |
# File 'lib/planter/seed_context.rb', line 29 def parent @parent end |
#seed_method ⇒ Symbol? (readonly)
The configured seeding method.
17 18 19 |
# File 'lib/planter/seed_context.rb', line 17 def seed_method @seed_method end |
#table_name ⇒ String (readonly)
The table being seeded.
11 12 13 |
# File 'lib/planter/seed_context.rb', line 11 def table_name @table_name end |
#unique_columns ⇒ Array<Symbol>? (readonly)
Columns used to look up existing records.
41 42 43 |
# File 'lib/planter/seed_context.rb', line 41 def unique_columns @unique_columns end |