torque-postgresql 0.2.1 → 0.2.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 979764ebdcc3d060ce4aab1c28de3dc4f0aff8b1
4
- data.tar.gz: e522c438e3d8d04f61d761d5738217b471724075
3
+ metadata.gz: 6422949dcd6390bea82ed290528491efd5b0effe
4
+ data.tar.gz: 797f069fd9b3a3207e39abfc781fc9c816ef3e72
5
5
  SHA512:
6
- metadata.gz: ccbc5797fdac9fecf2208acda837db28990235576848a22d389664237f45d6cc9d2cbfe6101aa1992615a2daad01f4fc6e1f792c59c18ed51d32a943f93fbfbd
7
- data.tar.gz: 20e7a8e8dbe6b4c4fc0eed20d84a003fc908a855da63ff7df00df2b6b9d706db21e28ecb36c5785156f663c6dc4ddb1168383c4d8e18dba1916f7b888f12ee02
6
+ metadata.gz: cf0c65ecca84216b3cf185fbeb4b5c4ef15de3a1e793a9071bf47e37dc0467ee6278ad4caba2db041874b39a3164689f3daa34b012055f38b82d52818ac3f487
7
+ data.tar.gz: 76d427aa302b392caa4552107f23252acb6c18608de0692b607f407e56c2fe5bba6a07fce2688708c702cd42c4b97e167bb331ab1098064a55c1b876975edc8e
@@ -1,5 +1,7 @@
1
1
  module Torque
2
2
  module PostgreSQL
3
+ LookupError = Class.new(ArgumentError)
4
+
3
5
  # :TODO: Create the +add+ to load inheritance info
4
6
  module SchemaCache
5
7
 
@@ -41,7 +43,7 @@ module Torque
41
43
  @data_sources_model_names.delete name
42
44
  @inheritance_dependencies.delete name
43
45
  @inheritance_associations.delete name
44
- @inheritance_cache -= 1
46
+ @inheritance_cache = inheritance_cache_key
45
47
  end
46
48
 
47
49
  def marshal_dump # :nodoc:
@@ -102,7 +104,11 @@ module Torque
102
104
  scopes.pop
103
105
  end
104
106
 
105
- nil
107
+ # If this part is reach, no model name was found
108
+ raise LookupError.new(<<~MSG.squish)
109
+ Unable to find a valid model that is associated with the '#{table_name}' table.
110
+ Please, check if they correctly inherit from ActiveRecord::Base
111
+ MSG
106
112
  end
107
113
 
108
114
  private
@@ -125,10 +131,14 @@ module Torque
125
131
  # Now iterate over
126
132
  while (condition = conditions.shift)
127
133
  ns_places.each{ |i| pieces[i] = condition.include?(i) ? '::' : '' }
128
- next unless scope.const_defined?(pieces.join)
134
+
135
+ candidate = pieces.join
136
+ candidate.prepend("#{scope.name}::") unless scope === Object
137
+
138
+ klass = candidate.safe_constantize
139
+ next if klass.nil?
129
140
 
130
141
  # Check if the class match the table name
131
- klass = scope.const_get(pieces.join)
132
142
  return klass if klass < ::ActiveRecord::Base && klass.table_name == table_name
133
143
  end
134
144
  end
@@ -146,8 +156,8 @@ module Torque
146
156
  return unless @inheritance_cache != cache_key
147
157
  @inheritance_cache = cache_key
148
158
 
149
- @inheritance_dependencies = connection.inherited_tables.freeze
150
- @inheritance_associations = generate_associations.freeze
159
+ @inheritance_dependencies = connection.inherited_tables
160
+ @inheritance_associations = generate_associations
151
161
  end
152
162
 
153
163
  # Calculates the inverted dependency (association), where even indirect
@@ -1,5 +1,5 @@
1
1
  module Torque
2
2
  module PostgreSQL
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torque-postgresql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Silva
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-18 00:00:00.000000000 Z
11
+ date: 2018-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails