summary refs log tree commit
diff options
context:
space:
mode:
authorAdrian Setyadi <a.styd@yahoo.com>2019-10-09 13:42:48 +0700
committerAdrian Setyadi <a.styd@yahoo.com>2019-10-09 13:43:38 +0700
commitabe0aadeccc154e3d53362c3b42e1d127185adec (patch)
tree14d738f6388beabccfa90e1a1f530c96231316e6
parent15871a51ad17d45ffb8229d4f9562a0b63390043 (diff)
downloadrack-abe0aadeccc154e3d53362c3b42e1d127185adec.tar.gz
Refine on the same file that uses it
-rw-r--r--lib/rack/core_ext/hash.rb19
-rw-r--r--lib/rack/session/abstract/id.rb14
2 files changed, 11 insertions, 22 deletions
diff --git a/lib/rack/core_ext/hash.rb b/lib/rack/core_ext/hash.rb
deleted file mode 100644
index f86a3611..00000000
--- a/lib/rack/core_ext/hash.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# frozen_string_literal: true
-
-# Hash has `transform_keys` since Ruby 2.5.
-# For Ruby < 2.5, we need to add the following
-
-module Rack
-  module HashExtensions
-    refine Hash do
-      def transform_keys(&block)
-        hash = {}
-        each do |key, value|
-          hash[block.call(key)] = value
-        end
-        hash
-      end unless {}.respond_to?(:transform_keys)
-    end
-  end
-end
-
diff --git a/lib/rack/session/abstract/id.rb b/lib/rack/session/abstract/id.rb
index 69dafe78..892f33de 100644
--- a/lib/rack/session/abstract/id.rb
+++ b/lib/rack/session/abstract/id.rb
@@ -9,8 +9,6 @@ require 'rack/request'
 require 'rack/response'
 require 'securerandom'
 
-require_relative '../../core_ext/hash'
-
 module Rack
 
   module Session
@@ -19,7 +17,17 @@ module Rack
       # SessionHash is responsible to lazily load the session from store.
 
       class SessionHash
-        using ::Rack::HashExtensions
+        using Module.new {
+          refine Hash do
+            def transform_keys(&block)
+              hash = {}
+              each do |key, value|
+                hash[block.call(key)] = value
+              end
+              hash
+            end unless {}.respond_to?(:transform_keys)
+          end
+        }
         include Enumerable
         attr_writer :id