Skip to content

Commit fbc60a6

Browse files
committed
Fix support for Ruby 2.1
It seems Ruby changed how `nil` behaves between 2.1 and 2.2. - Ruby 2.1 ```ruby nil.frozen? # => false ``` - Ruby 2.2 ```ruby nil.frozen? # => true ``` We anticipate that most values will not be `nil` and most of the Rails apps are already on Ruby 2.2. Additionally, under heavier loads all but the first read will already be frozen. So we place the `nil` check as the 2nd predicate as we usually won't need it.
1 parent b8b9104 commit fbc60a6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/kracken/controllers/token_authenticatable.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ def cache_valid_auth(token, &generate_cache)
4949
end
5050

5151
def shallow_freeze(val)
52-
# nil is always frozen
53-
return val if val.frozen?
52+
# `nil` is frozen in Ruby 2.2 but not in Ruby 2.1
53+
return val if val.frozen? || val.nil?
5454
val.transform_values!(&:freeze).freeze
5555
end
5656

0 commit comments

Comments
 (0)