encoded_id-rails 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of encoded_id-rails might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/encoded_id/rails/model.rb +14 -2
- data/lib/encoded_id/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 245fb340a94ca73cff62e2e466ee1f6a8f10195b1df94e0c1d37334c66168925
|
4
|
+
data.tar.gz: ffdecb93e8b75ddd0e63da9f5c3d686f80e986fb73035c27bb57882c1982723d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1add38768e797d2e57270a600bd84717141edcdd955c4e5b91c38cfc9585f8aa207099d737bae6f68d2f1364aace46877f50ea014ab2063a44fa718a2ace98a
|
7
|
+
data.tar.gz: 47629d384bca18518bbf69645c9e0e8c4ddb0fb1bd064fa006593e3d7ac32d78951486ff442ad6b0d7012a4fbdeb8c79268998e518d24a4435caa7dc9226ebeb
|
data/CHANGELOG.md
CHANGED
@@ -13,11 +13,15 @@ module EncodedId
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def encoded_id
|
16
|
-
|
16
|
+
return unless id
|
17
|
+
return @encoded_id if defined?(@encoded_id) && !id_changed?
|
18
|
+
@encoded_id = self.class.encode_encoded_id(id)
|
17
19
|
end
|
18
20
|
|
19
21
|
def slugged_encoded_id(with: :name_for_encoded_id_slug)
|
20
|
-
|
22
|
+
return unless id
|
23
|
+
return @slugged_encoded_id if defined?(@slugged_encoded_id) && !id_changed?
|
24
|
+
@slugged_encoded_id = EncodedId::Rails::SluggedId.new(
|
21
25
|
self,
|
22
26
|
slug_method: with,
|
23
27
|
id_method: :encoded_id,
|
@@ -31,6 +35,14 @@ module EncodedId
|
|
31
35
|
raise StandardError, "Class must have a `name`, cannot create a slug" if !class_name || class_name.blank?
|
32
36
|
class_name.underscore
|
33
37
|
end
|
38
|
+
|
39
|
+
# When duplicating an ActiveRecord object, we want to reset the memoized encoded_id
|
40
|
+
def dup
|
41
|
+
super.tap do |new_record|
|
42
|
+
new_record.instance_variable_set(:@encoded_id, nil)
|
43
|
+
new_record.instance_variable_set(:@slugged_encoded_id, nil)
|
44
|
+
end
|
45
|
+
end
|
34
46
|
end
|
35
47
|
end
|
36
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: encoded_id-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Ierodiaconou
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|