1
0
Fork 0
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:
Rafael Mendonça França 2015-01-04 16:00:22 -03:00
parent 065c20890a
commit 758e223c45
4 changed files with 5 additions and 18 deletions

View file

@ -1,7 +1,6 @@
require 'active_support/core_ext/hash/slice'
require 'active_support/core_ext/hash/except'
require 'active_support/core_ext/module/anonymous'
require 'active_support/core_ext/struct'
require 'action_dispatch/http/mime_type'
module ActionController

View file

@ -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
end

View file

@ -1,6 +1,3 @@
# Backport of Struct#to_h from Ruby 2.0
class Struct # :nodoc:
def to_h
Hash[members.zip(values)]
end
end unless Struct.instance_methods.include?(:to_h)
require 'active_support/deprecation'
ActiveSupport::Deprecation.warn("This file is deprecated and will be removed in Rails 5.1 with no replacement.")

View file

@ -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