Module: SeedDumpling::Environment
- Extended by:
- ActiveSupport::Concern
- Included in:
- SeedDumpling
- Defined in:
- lib/seed_dumpling/environment.rb
Overview
Provides functionality for dumping database records to seed files using environment variables to configure the dump process. Supports model filtering, batch processing, and various output options.
Instance Method Summary collapse
-
#dump_using_environment(env = {}) ⇒ Object
rubocop:disable Metrics/MethodLength.
Instance Method Details
#dump_using_environment(env = {}) ⇒ Object
rubocop:disable Metrics/MethodLength
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/seed_dumpling/environment.rb', line 16 def dump_using_environment(env = {}) # rubocop:disable Metrics/MethodLength Rails.application.eager_load! models = retrieve_models(env) - retrieve_models_exclude(env) limit = retrieve_limit_value(env) append = retrieve_append_value(env) models.each do |model| model = model.limit(limit) if limit.present? SeedDumpling.dump(model, append: append, batch_size: retrieve_batch_size_value(env), exclude: retrieve_exclude_value(env), file: retrieve_file_value(env), import: retrieve_import_value(env), ) append = true # Always append for every model after the first # (append for the first model is determined by # the APPEND environment variable). end end |