Module: SeedDump::Environment

Included in:
SeedDump
Defined in:
lib/seed_dump/environment.rb

Instance Method Summary collapse

Instance Method Details

#dump_using_environment(env = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/seed_dump/environment.rb', line 4

def dump_using_environment(env = {})
  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?

    SeedDump.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