AMS 0.8: Fix memory leak with :scope_name (#1675)

Fix memory leak with :scope_name

Supplying :scope_name causes `ActiveModel::Serializer#initialize` to
define a method on the class, which retains a reference to the
serializer instance.

* Lock version of mime-types to < 3 for older JRubies
This commit is contained in:
Dries Harnie 2016-04-13 06:54:33 +02:00 committed by Benjamin Fleischer
parent e54d129091
commit 07addbf8c7
2 changed files with 6 additions and 3 deletions

View File

@ -31,3 +31,8 @@ end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: (@windows_platforms + [:jruby])
# JRuby versions before 9.x report their version as "1.9.x" or lower, so lock these to an older version of mime-types
if defined?(JRUBY_VERSION) and Gem::ruby_version < Gem::Version.new("2.0.0")
gem 'mime-types', '< 3'
end

View File

@ -294,9 +294,7 @@ module ActiveModel
scope_name = @options[:scope_name]
if scope_name && !respond_to?(scope_name)
self.class.class_eval do
define_method scope_name, lambda { scope }
end
self.singleton_class.send :alias_method, scope_name, :scope
end
end