Class: SeedFu::Seeder
- Inherits:
-
Object
- Object
- SeedFu::Seeder
- Defined in:
- lib/seed-fu-ndo/seeder.rb
Overview
Enhanced class from Seed Fu to allow for recording and destroying seed data.
Instance Method Summary collapse
-
#seed_with_undo ⇒ Object
Record instead of inserting the data if in recording mode.
-
#unseed ⇒ Object
Destroy the seed data.
Instance Method Details
#seed_with_undo ⇒ Object
Record instead of inserting the data if in recording mode.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/seed-fu-ndo/seeder.rb', line 7 def seed_with_undo if r = SeedFuNdo.recorder r.record self # return existing records in case they are processed by the caller @data.map { |record_data| find_record(record_data) } else seed_without_undo end end |
#unseed ⇒ Object
Destroy the seed data.
20 21 22 23 24 |
# File 'lib/seed-fu-ndo/seeder.rb', line 20 def unseed @model_class.transaction do @data.reverse.map { |record_data| unseed_record(record_data.symbolize_keys) } end end |