hashid-rails 1.3.0 → 1.4.0

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: ff1db9b357cb0791da90ba58f86c3193d8f02fa9585099c18a90edb274bb4dbe
4
- data.tar.gz: 11b31881df97678fda33e38eb42153b245b9f0672e823f3cae57219586a178b9
3
+ metadata.gz: a031cc6356d93f71fa6d698df56e16ca80cc618f48124bc2d96f280f0d377b7c
4
+ data.tar.gz: 0e1fae45b1e6398f270dc537809c66f194b46b66c45b517c9f3fbb4c836e7a92
5
5
  SHA512:
6
- metadata.gz: 9fedf05af138f2efbeb4e1caedafc0ab844946cba287e085bd4446f49a218f4f44926602b36d26a5d06b2792d49f7b0e37121230c561d6b13ad351fa8e3e56f0
7
- data.tar.gz: db9d9f9740bca29e8b0bf33ac2d1598a98a34516368a7d503bf10bfe71f8cbc147819934675eb1dda46bfddf32acff25705a0133f4ddc85a2f424e4842e41426
6
+ metadata.gz: 6192fcc1bc64d6fd20eaa2fd57c382327a47b52dc2511d69db6611a610b8ff940c45962223e2aff4336467454937145bfb58944d305041972605f69b470d092d
7
+ data.tar.gz: 88a4be52b6b208d3d858eb37d9a97255f064476639a3d80add4e19ba0bff39d9cb2024edaa156625de6509d386e341850efdf20f3d03c663854bccef2668dc6d
@@ -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
@@ -33,7 +33,10 @@ module Hashid
33
33
  def hashid
34
34
  self.class.encode_id(id)
35
35
  end
36
- alias to_param hashid
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
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Hashid
4
4
  module Rails
5
- VERSION = "1.3.0"
5
+ VERSION = "1.4.0"
6
6
  end
7
7
  end
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.3.0
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-30 00:00:00.000000000 Z
11
+ date: 2019-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler