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: 4534409fced9bb961b30e224eb1eb820d7fbc39c
4
- data.tar.gz: c9c6dd35d78aab01b3b71ab316401c97c566fdd5
3
+ metadata.gz: 4a521e0101e57bf47a2a8df391c3850804b62ef7
4
+ data.tar.gz: c4f29ade6c101e661120b6202494f8b78b68f97d
5
5
  SHA512:
6
- metadata.gz: 233d85149243faf8f82bacecbc2c65b297ac816140b713605ed9a76312a586e8780b1588d25c84208e05a023f6844635e2fb82e79da0fb26a5b7248b55aff6f2
7
- data.tar.gz: b225e0805790115a6c3a9912ca2a3c598a8010eeaa7fdf81a63f418196a16e18a38f49bc630d94ec4a048feb977d2c28729927b85f4b4c0ad2480a1f9a530227
6
+ metadata.gz: f7677a6cbf7e3683f633096a99d52d9b1b82155aaae1e874a2388af892f57f44c64836b324f756e9f2d6f388ad91aa2bb11ccfac4fd922c43aa03613c4df5a52
7
+ data.tar.gz: 1e0880bfb6659adbaf211536ae880ea119de962f9c5f9e0051e830feee32600332056f69cdfa5c39b8c5d3a9c696afe338af8206a092035888aad6123e4ba935
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  /gemfiles/**/*.lock
11
+ /**/.bundle
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, a little window appears at the
25
- bottom of the page. This is inspired by [Bullet](https://github.com/flyerhzm/bullet).
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.1', platforms: [:ruby, :mswin, :mswin64, :mingw, :x64_mingw]
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
- reflection = env.model.reflect_on_association(env.name)
10
- if !reflection.polymorphic? && !reflection.has_inverse?
11
- raise ActiveRecord::InverseOfAssociationNotFoundError.new(reflection)
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.3'
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.3
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-13 00:00:00.000000000 Z
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