mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove Struct#to_h backport
This commit is contained in:
parent
065c20890a
commit
758e223c45
4 changed files with 5 additions and 18 deletions
|
@ -1,7 +1,6 @@
|
||||||
require 'active_support/core_ext/hash/slice'
|
require 'active_support/core_ext/hash/slice'
|
||||||
require 'active_support/core_ext/hash/except'
|
require 'active_support/core_ext/hash/except'
|
||||||
require 'active_support/core_ext/module/anonymous'
|
require 'active_support/core_ext/module/anonymous'
|
||||||
require 'active_support/core_ext/struct'
|
|
||||||
require 'action_dispatch/http/mime_type'
|
require 'action_dispatch/http/mime_type'
|
||||||
|
|
||||||
module ActionController
|
module ActionController
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
Dir["#{File.dirname(__FILE__)}/core_ext/*.rb"].each do |path|
|
DEPRECATED_FILES = ["#{File.dirname(__FILE__)}/core_ext/struct.rb"]
|
||||||
|
(Dir["#{File.dirname(__FILE__)}/core_ext/*.rb"] - DEPRECATED_FILES).each do |path|
|
||||||
require path
|
require path
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
# Backport of Struct#to_h from Ruby 2.0
|
require 'active_support/deprecation'
|
||||||
class Struct # :nodoc:
|
|
||||||
def to_h
|
ActiveSupport::Deprecation.warn("This file is deprecated and will be removed in Rails 5.1 with no replacement.")
|
||||||
Hash[members.zip(values)]
|
|
||||||
end
|
|
||||||
end unless Struct.instance_methods.include?(:to_h)
|
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
require 'abstract_unit'
|
|
||||||
require 'active_support/core_ext/struct'
|
|
||||||
|
|
||||||
class StructExt < ActiveSupport::TestCase
|
|
||||||
def test_to_h
|
|
||||||
x = Struct.new(:foo, :bar)
|
|
||||||
z = x.new(1, 2)
|
|
||||||
assert_equal({ foo: 1, bar: 2 }, z.to_h)
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue