Module: SeedMigrator::Seeds
- Includes:
- UpdateClassLoader
- Defined in:
- lib/seed_migrator/seeds.rb
Overview
Should be included in seeds.rb to enable running data updates.
Instance Method Summary collapse
-
#apply_updates(updates_path) ⇒ Hash
Applies all the updates from the given file system path.
Methods included from UpdateClassLoader
Instance Method Details
#apply_updates(updates_path) ⇒ Hash
Applies all the updates from the given file system path.
Basically, requires all the files from the given directory with a .rb suffix, instantiates the class in the file, and calls ‘perform_update’ on it. This naturally requires that classes obey the default naming convention, i.e. a file named sample_update.rb should define a class named SampleUpdate.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/seed_migrator/seeds.rb', line 17 def apply_updates(updates_path) update_files = get_update_files(updates_path) results = {} update_files.each { |file| update = file.split('.').first unless update.blank? update_class = get_update_class(updates_path, update) res = update_class.new.perform_update results[update] = res end } results end |