rare_map 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,7 +27,11 @@ module RareMap
27
27
  private
28
28
  def build_relations(models)
29
29
  models.each do |model|
30
- group_models = models.select { |m| m.group == model.group && m.db_name == model.db_name }
30
+ if model.group?
31
+ group_models = models.select { |m| m.group == model.group }
32
+ else
33
+ group_models = models.select { |m| m.group == model.group && m.db_name == model.db_name }
34
+ end
31
35
 
32
36
  group_models.each do |gm|
33
37
  model.table.columns.each do |col|
@@ -47,16 +51,23 @@ module RareMap
47
51
  models.each do |model|
48
52
  model.relations.each do |rel_from|
49
53
  model.relations.each do |rel_to|
50
- if rel_from != rel_to &&
51
- rel_from.type == :belongs_to &&
52
- rel_to.type == :belongs_to &&
53
- rel_from.table != rel_to.table
54
- model_from = models.find { |m| m.table.name == rel_from.table &&
54
+ if rel_from != rel_to && rel_from.table != rel_to.table &&
55
+ rel_from.type == :belongs_to && rel_to.type == :belongs_to
56
+
57
+ if model.group?
58
+ model_from = models.find { |m| m.table.name == rel_from.table &&
59
+ m.group == model.group }
60
+ model_to = models.find { |m| m.table.name == rel_to.table &&
61
+ m.group == model.group }
62
+ else
63
+ model_from = models.find { |m| m.table.name == rel_from.table &&
64
+ m.group == model.group &&
65
+ m.db_name == model.db_name }
66
+ model_to = models.find { |m| m.table.name == rel_to.table &&
55
67
  m.group == model.group &&
56
68
  m.db_name == model.db_name }
57
- model_to = models.find { |m| m.table.name == rel_to.table &&
58
- m.group == model.group &&
59
- m.db_name == model.db_name }
69
+ end
70
+
60
71
  model_from.relations << Relation.new(:has_many_through, rel_to.foreign_key, model_to.table.name, model.table.name)
61
72
  model_to.relations << Relation.new(:has_many_through, rel_from.foreign_key, model_from.table.name, model.table.name)
62
73
  end
@@ -62,9 +62,15 @@ module RareMap
62
62
 
63
63
  private
64
64
  def classify_by_table(table, model, models)
65
- model = models.find { |m| m.table.name == table &&
66
- m.group == model.group &&
67
- m.db_name == model.db_name }
65
+ if model.group?
66
+ model = models.find { |m| m.table.name == table &&
67
+ m.group == model.group }
68
+ else
69
+ model = models.find { |m| m.table.name == table &&
70
+ m.group == model.group &&
71
+ m.db_name == model.db_name }
72
+ end
73
+
68
74
  model.classify
69
75
  end
70
76
 
@@ -1,7 +1,7 @@
1
1
  module RareMap
2
2
  MAJOR = 2
3
3
  MINOR = 0
4
- PATCH = 0
4
+ PATCH = 1
5
5
 
6
6
  VERSION = [MAJOR, MINOR, PATCH].compact.join('.')
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rare_map
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-04 00:00:00.000000000 Z
12
+ date: 2013-03-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -144,7 +144,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
144
  version: '0'
145
145
  segments:
146
146
  - 0
147
- hash: 2598832910408143833
147
+ hash: -794521920480426625
148
148
  required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
@@ -153,13 +153,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  version: '0'
154
154
  segments:
155
155
  - 0
156
- hash: 2598832910408143833
156
+ hash: -794521920480426625
157
157
  requirements: []
158
158
  rubyforge_project:
159
159
  rubygems_version: 1.8.25
160
160
  signing_key:
161
161
  specification_version: 3
162
- summary: rare_map-2.0.0
162
+ summary: rare_map-2.0.1
163
163
  test_files:
164
164
  - test/helper.rb
165
165
  - test/test_rare_map.rb