prefixed_ids 1.9.1 → 1.9.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
  SHA256:
3
- metadata.gz: 7b277a81ffce06f880d103b39475fe1a31ea6a5b500d1e6d79bd6c94df2628c3
4
- data.tar.gz: b1f2e91a1da643822be3fbb51a13eff396215a439a80ef69f79407d4162d6a49
3
+ metadata.gz: 9f4a7dba39c3feff4c04155095501305cda1f83649a3084587276762bba4bf43
4
+ data.tar.gz: 94f8821fbe8f4b6144d9f1d88fad5c86d91f6b92c69718d5584214724d07d89e
5
5
  SHA512:
6
- metadata.gz: faefa73733550962611641d5dee88178c13a11f0807c6f2e6237a8ceb523175b255e51c1d3738acf1c565305f39b0834d80aa2b58f69c56740efda944faf1f33
7
- data.tar.gz: f0eaafaa720fb989ff0b11dcecdd6d22e3103303b23471b3c8af286332cc0962695435f5decff563ef614783c5fc17860f9afc042cd13988c977f192695fe3a3
6
+ metadata.gz: 800ac6f9df59cfe8d75a9606e66ee926f0d03eff86360d3ff23b1f1286a4746ca04d865e89ac2fabd377d0632310abbcfc7b37980ef2b595d0eb8e6f14ef0a3d
7
+ data.tar.gz: 9c90c492213661c063cdbe3510369fee96958fc00845a18cb6c831f3741bdd2a6ee52ebf6b94ceb1d2a55ee9fdd769b0526dddd9e4a8a4af8979604a2cbbd30b
@@ -1,3 +1,3 @@
1
1
  module PrefixedIds
2
- VERSION = "1.9.1"
2
+ VERSION = "1.9.2"
3
3
  end
data/lib/prefixed_ids.rb CHANGED
@@ -166,13 +166,11 @@ module PrefixedIds
166
166
  super.tap { |r| r.extend ClassMethods }
167
167
  end
168
168
 
169
- def belongs_to(*args, **options, &block)
170
- association = super
169
+ def belongs_to(name, *args, **options, &block)
170
+ super
171
171
 
172
- name = args.first
173
- reflection = association[name] || association[name.to_s]
174
-
175
- return association if reflection.polymorphic?
172
+ reflection = reflect_on_association(name)
173
+ return if reflection.polymorphic?
176
174
 
177
175
  # Skip helpers if the associated class can't be loaded yet, so Rails only raises when the association is used
178
176
  klass = begin
@@ -180,7 +178,7 @@ module PrefixedIds
180
178
  rescue NameError
181
179
  nil
182
180
  end
183
- return association if klass.nil? || klass._prefix_id.blank?
181
+ return if klass.nil? || klass._prefix_id.blank?
184
182
 
185
183
  generated_association_methods.class_eval <<-CODE, __FILE__, __LINE__ + 1
186
184
  def #{name}_prefix_id
@@ -192,8 +190,6 @@ module PrefixedIds
192
190
  send("#{reflection.foreign_key}=", decoded_id)
193
191
  end
194
192
  CODE
195
-
196
- association
197
193
  end
198
194
 
199
195
  def has_many(*args, &block)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prefixed_ids
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.1
4
+ version: 1.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver