schema_plus_association_inverses 0.0.3 → 0.0.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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a521e0101e57bf47a2a8df391c3850804b62ef7
|
4
|
+
data.tar.gz: c4f29ade6c101e661120b6202494f8b78b68f97d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7677a6cbf7e3683f633096a99d52d9b1b82155aaae1e874a2388af892f57f44c64836b324f756e9f2d6f388ad91aa2bb11ccfac4fd922c43aa03613c4df5a52
|
7
|
+
data.tar.gz: 1e0880bfb6659adbaf211536ae880ea119de962f9c5f9e0051e830feee32600332056f69cdfa5c39b8c5d3a9c696afe338af8206a092035888aad6123e4ba935
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -21,8 +21,11 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
## Usage
|
23
23
|
|
24
|
-
When a model requiring manual declaration of the inverse is detected,
|
25
|
-
|
24
|
+
When a model requiring manual declaration of the inverse is detected, an
|
25
|
+
`ActiveRecord::InverseOfAssociationNotFoundError` is raised.
|
26
|
+
|
27
|
+
To specify that an association does not have an inverse, explicitly set `inverse_of` on the
|
28
|
+
relation to `false` or `nil`.
|
26
29
|
|
27
30
|
## Contributing
|
28
31
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "pathname"
|
2
2
|
eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
|
3
3
|
|
4
|
-
gem "pg", '~> 0.17.
|
4
|
+
gem "pg", '~> 0.17.0'
|
5
5
|
|
6
6
|
platform :jruby do
|
7
7
|
gem 'activerecord-jdbcpostgresql-adapter'
|
@@ -6,9 +6,22 @@ module SchemaPlus::AssociationInverses
|
|
6
6
|
module Declaration
|
7
7
|
|
8
8
|
def after(env)
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
model = env.model
|
10
|
+
reflection = model.reflect_on_association(env.name)
|
11
|
+
|
12
|
+
# Cannot check polymorphic relationships
|
13
|
+
return if reflection.polymorphic?
|
14
|
+
|
15
|
+
# Cannot check HABTM relationships, models, or through: relationships
|
16
|
+
return if model.name =~ /^HABTM_/
|
17
|
+
return if reflection.is_a?(ActiveRecord::Reflection::HasAndBelongsToManyReflection)
|
18
|
+
return if reflection.is_a?(ActiveRecord::Reflection::ThroughReflection)
|
19
|
+
|
20
|
+
# Explicitly ignored
|
21
|
+
return if reflection.options.key?(:inverse_of) && !reflection.options[:inverse_of]
|
22
|
+
|
23
|
+
if !reflection.has_inverse?
|
24
|
+
raise ActiveRecord::InverseOfAssociationNotFoundError.new(reflection, model)
|
12
25
|
end
|
13
26
|
end
|
14
27
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
module SchemaPlus
|
2
|
-
module AssociationInverses
|
3
|
-
VERSION = '0.0.
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
1
|
+
module SchemaPlus
|
2
|
+
module AssociationInverses
|
3
|
+
VERSION = '0.0.4'
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_plus_association_inverses
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Low
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: schema_plus_core
|