rare_map 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -53,10 +53,10 @@ module RareMap
53
53
  rel_from.table != rel_to.table
54
54
  model_from = models.find { |m| m.table.name == rel_from.table &&
55
55
  m.group == model.group &&
56
- m.db_name == model.db_name }
56
+ m.db_name == model.db_name }
57
57
  model_to = models.find { |m| m.table.name == rel_to.table &&
58
58
  m.group == model.group &&
59
- m.db_name == model.db_name }
59
+ m.db_name == model.db_name }
60
60
  model_from.relations << Relation.new(:has_many_through, rel_to.foreign_key, model_to.table.name, model.table.name)
61
61
  model_to.relations << Relation.new(:has_many_through, rel_from.foreign_key, model_from.table.name, model.table.name)
62
62
  end
@@ -69,14 +69,15 @@ module RareMap
69
69
  def generate_connection_models(models, path)
70
70
  group_db2conn = {}
71
71
 
72
- group2connection = Hash[models.map { |model| [[model.group, model.db_name], model.connection] }]
73
- group2connection.each do |(group, db_name), connection|
72
+ group2connection = Hash[models.map { |model| [[model.group, model.db_name], [model.connection, model.table.name]] }]
73
+ group2connection.each do |(group, db_name), (connection, table_name)|
74
74
  model = "#{group}_#{db_name}".camelize + 'Base'
75
75
 
76
76
  output = ''
77
77
  output <<
78
78
  "class #{model} < ActiveRecord::Base\n" <<
79
79
  " establish_connection #{connection.map { |k, v| ":#{k} => #{v.inspect}" }.join(', ')}\n" <<
80
+ " self.table_name = '#{table_name}'\n" <<
80
81
  'end'
81
82
 
82
83
 
@@ -2,7 +2,7 @@ class RareMap
2
2
  module Version
3
3
  MAJOR = 1
4
4
  MINOR = 2
5
- PATCH = 0
5
+ PATCH = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  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: 1.2.0
4
+ version: 1.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -142,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  segments:
144
144
  - 0
145
- hash: -2379119052270473471
145
+ hash: -2233758671906333184
146
146
  required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  none: false
148
148
  requirements: