remove patches that have been upstreamed

clean up rails4 checks so they are consistent
This commit is contained in:
Sam 2013-09-12 15:39:02 +10:00
parent 00951e0578
commit 691377b5af
6 changed files with 23 additions and 77 deletions

View File

@ -1,4 +1,4 @@
unless Rails.version =~ /^4/
unless rails4?
module ActiveRecord
class Relation
# Patch Rails 3 ActiveRecord::Relation to noop on Rails 4 references

View File

@ -1,33 +0,0 @@
#see: https://github.com/rails/rails/pull/12065
if rails4?
module ActiveRecord
class Result
private
def hash_rows
@hash_rows ||=
begin
# We freeze the strings to prevent them getting duped when
# used as keys in ActiveRecord::Base's @attributes hash
columns = @columns.map { |c| c.dup.freeze }
@rows.map { |row|
# In the past we used Hash[columns.zip(row)]
# though elegant, the verbose way is much more efficient
# both time and memory wise cause it avoids a big array allocation
# this method is called a lot and needs to be micro optimised
hash = {}
index = 0
length = columns.length
while index < length
hash[columns[index]] = row[index]
index += 1
end
hash
}
end
end
end
end
end

View File

@ -1,22 +0,0 @@
# see PR: https://github.com/rails/rails/pull/12185
#
class ActiveRecord::Associations::JoinDependency::JoinPart
def extract_record(row)
# Used to be: Hash[column_names_with_alias.map{|cn, an| [cn, row[an]]}]
# that is fairly inefficient cause all the values are first copied
# in to an array only to construct the Hash
# This code is performance critical as it is called per row.
hash = {}
index = 0
while index < column_names_with_alias.length do
cn,an = column_names_with_alias[index]
hash[cn] = row[an]
index += 1
end
hash
end
end

View File

@ -10,6 +10,7 @@ class ActiveRecord::Base
end
end
unless rails4?
class ActionView::Helpers::AssetTagHelper::AssetIncludeTag
private
@ -31,6 +32,6 @@ private
plural = @@pluralization_cache[asset_name] ||= asset_name.to_s.pluralize
end
end
end

View File

@ -1,4 +1,4 @@
unless Rails.version =~ /^4/
unless rails4?
module HTML
class WhiteListSanitizer
# Sanitizes a block of css code. Used by #sanitize when it comes across a style attribute

View File

@ -97,7 +97,7 @@ module RailsMultisite
# see: https://github.com/rails/rails/issues/8344#issuecomment-10800848
#
@@default_connection_handler = ActiveRecord::Base.connection_handler
ActiveRecord::Base.send :include, NewConnectionHandler
ActiveRecord::Base.send :include, NewConnectionHandler if ActiveRecord::VERSION::MAJOR == 3
ActiveRecord::Base.connection_handler = @@default_connection_handler
@@connection_handlers = {}
end