seedomatic 0.5.3 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,6 +23,8 @@ module SeedOMatic
23
23
  updated_records += 1
24
24
  end
25
25
 
26
+ clean_up_associations(model, attrs)
27
+
26
28
  if model.new_record? || seed_mode == 'always'
27
29
  model.attributes = process_lookups(attrs)
28
30
  model.save!
@@ -34,6 +36,16 @@ module SeedOMatic
34
36
 
35
37
  protected
36
38
 
39
+ def clean_up_associations(model, attrs)
40
+ attrs.select{|a| a.ends_with?('attributes')}.each do |key, value|
41
+ association = key.gsub("_attributes", "").to_sym
42
+
43
+ if model_class.reflect_on_association(association).collection?
44
+ model_class.send(association).destroy_all
45
+ end
46
+ end
47
+ end
48
+
37
49
  def process_lookups(attrs)
38
50
  attrs.select{|k| k.ends_with? "_lookup"}.each do |key, value|
39
51
  attrs.delete(key)
@@ -1,3 +1,3 @@
1
1
  module Seedomatic
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seedomatic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-16 00:00:00.000000000 Z
12
+ date: 2012-06-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70359766137340 !ruby/object:Gem::Requirement
16
+ requirement: &70326155303220 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.9.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70359766137340
24
+ version_requirements: *70326155303220
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activesupport
27
- requirement: &70359766136920 !ruby/object:Gem::Requirement
27
+ requirement: &70326155301100 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70359766136920
35
+ version_requirements: *70326155301100
36
36
  description: Create repeatable seed fixtures that you can continually use and deploy
37
37
  to multiple environments and tenants.
38
38
  email: