hashid-rails 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +3 -0
- data/lib/hashid/rails.rb +6 -1
- data/lib/hashid/rails/configuration.rb +2 -0
- data/lib/hashid/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: a031cc6356d93f71fa6d698df56e16ca80cc618f48124bc2d96f280f0d377b7c
|
4
|
+
data.tar.gz: 0e1fae45b1e6398f270dc537809c66f194b46b66c45b517c9f3fbb4c836e7a92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6192fcc1bc64d6fd20eaa2fd57c382327a47b52dc2511d69db6611a610b8ff940c45962223e2aff4336467454937145bfb58944d305041972605f69b470d092d
|
7
|
+
data.tar.gz: 88a4be52b6b208d3d858eb37d9a97255f064476639a3d80add4e19ba0bff39d9cb2024edaa156625de6509d386e341850efdf20f3d03c663854bccef2668dc6d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.4.0 (2019-10-30)
|
4
|
+
- Add support for disabling the overriding of `to_param` ([#68](https://github.com/jcypret/hashid-rails/pull/68))
|
5
|
+
- Fix exception raised when calling `hashid` on an model with a `nil` id
|
6
|
+
([#63](https://github.com/jcypret/hashid-rails/pull/63) by [fauxparse](https://github.com/fauxparse))
|
7
|
+
|
3
8
|
## 1.3.0 (2019-10-29)
|
4
9
|
- Add support for model-level config ([#67](https://github.com/jcypret/hashid-rails/pull/67))
|
5
10
|
|
data/README.md
CHANGED
@@ -109,6 +109,9 @@ Hashid::Rails.configure do |config|
|
|
109
109
|
# Whether to override the `find` method
|
110
110
|
config.override_find = true
|
111
111
|
|
112
|
+
# Whether to override the `to_param` method
|
113
|
+
config.override_to_param = true
|
114
|
+
|
112
115
|
# Whether to sign hashids to prevent conflicts with regular IDs (see https://github.com/jcypret/hashid-rails/issues/30)
|
113
116
|
config.sign_hashids = true
|
114
117
|
end
|
data/lib/hashid/rails.rb
CHANGED
@@ -33,7 +33,10 @@ module Hashid
|
|
33
33
|
def hashid
|
34
34
|
self.class.encode_id(id)
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
|
+
def to_param
|
38
|
+
self.class.hashid_configuration.override_to_param ? hashid : super
|
39
|
+
end
|
37
40
|
|
38
41
|
module ClassMethods
|
39
42
|
def hashid_config(options = {})
|
@@ -110,6 +113,8 @@ module Hashid
|
|
110
113
|
end
|
111
114
|
|
112
115
|
def hashid_encode(id)
|
116
|
+
return nil if id.nil?
|
117
|
+
|
113
118
|
if hashid_configuration.sign_hashids
|
114
119
|
hashids.encode(HASHID_TOKEN, id)
|
115
120
|
else
|
@@ -8,6 +8,7 @@ module Hashid
|
|
8
8
|
:min_hash_length,
|
9
9
|
:alphabet,
|
10
10
|
:override_find,
|
11
|
+
:override_to_param,
|
11
12
|
:sign_hashids
|
12
13
|
|
13
14
|
def initialize
|
@@ -18,6 +19,7 @@ module Hashid
|
|
18
19
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
|
19
20
|
"1234567890"
|
20
21
|
@override_find = true
|
22
|
+
@override_to_param = true
|
21
23
|
@sign_hashids = true
|
22
24
|
end
|
23
25
|
|
data/lib/hashid/rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hashid-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Cypret
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|