aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/callbacks.rb19
-rw-r--r--activesupport/lib/active_support/json/encoding.rb1
-rw-r--r--activesupport/lib/active_support/json/variable.rb9
-rw-r--r--activesupport/lib/active_support/testing/performance/ruby.rb5
4 files changed, 21 insertions, 13 deletions
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb
index a9253c186d..0aa3efbb63 100644
--- a/activesupport/lib/active_support/callbacks.rb
+++ b/activesupport/lib/active_support/callbacks.rb
@@ -328,17 +328,26 @@ module ActiveSupport
# if it was not yet defined.
# This generated method plays caching role.
def __define_callbacks(kind, object) #:nodoc:
- chain = object.send("_#{kind}_callbacks")
- name = "_run_callbacks_#{chain.object_id.abs}"
+ name = __callback_runner_name(kind)
unless object.respond_to?(name, true)
+ str = object.send("_#{kind}_callbacks").compile
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
- def #{name}() #{chain.compile} end
+ def #{name}() #{str} end
protected :#{name}
RUBY_EVAL
end
name
end
+ def __reset_runner(symbol)
+ name = __callback_runner_name(symbol)
+ undef_method(name) if method_defined?(name)
+ end
+
+ def __callback_runner_name(kind)
+ "_run__#{self.name.hash.abs}__#{kind}__callbacks"
+ end
+
# This is used internally to append, prepend and skip callbacks to the
# CallbackChain.
#
@@ -350,6 +359,7 @@ module ActiveSupport
([self] + ActiveSupport::DescendantsTracker.descendants(self)).reverse.each do |target|
chain = target.send("_#{name}_callbacks")
yield target, chain.dup, type, filters, options
+ target.__reset_runner(name)
end
end
@@ -437,9 +447,12 @@ module ActiveSupport
chain = target.send("_#{symbol}_callbacks").dup
callbacks.each { |c| chain.delete(c) }
target.send("_#{symbol}_callbacks=", chain)
+ target.__reset_runner(symbol)
end
self.send("_#{symbol}_callbacks=", callbacks.dup.clear)
+
+ __reset_runner(symbol)
end
# Define sets of events in the object lifecycle that support callbacks.
diff --git a/activesupport/lib/active_support/json/encoding.rb b/activesupport/lib/active_support/json/encoding.rb
index 59709a19f1..c319e94bc6 100644
--- a/activesupport/lib/active_support/json/encoding.rb
+++ b/activesupport/lib/active_support/json/encoding.rb
@@ -1,6 +1,5 @@
require 'active_support/core_ext/object/to_json'
require 'active_support/core_ext/module/delegation'
-require 'active_support/json/variable'
require 'bigdecimal'
require 'active_support/core_ext/big_decimal/conversions' # for #to_s
diff --git a/activesupport/lib/active_support/json/variable.rb b/activesupport/lib/active_support/json/variable.rb
deleted file mode 100644
index 5685ed18b7..0000000000
--- a/activesupport/lib/active_support/json/variable.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-module ActiveSupport
- module JSON
- # A string that returns itself as its JSON-encoded form.
- class Variable < String
- def as_json(options = nil) self end #:nodoc:
- def encode_json(encoder) self end #:nodoc:
- end
- end
-end
diff --git a/activesupport/lib/active_support/testing/performance/ruby.rb b/activesupport/lib/active_support/testing/performance/ruby.rb
index 1104fc0a03..12aef0d7fe 100644
--- a/activesupport/lib/active_support/testing/performance/ruby.rb
+++ b/activesupport/lib/active_support/testing/performance/ruby.rb
@@ -18,6 +18,7 @@ module ActiveSupport
end).freeze
protected
+ remove_method :run_gc
def run_gc
GC.start
end
@@ -28,6 +29,7 @@ module ActiveSupport
@supported = @metric.measure_mode rescue false
end
+ remove_method :run
def run
return unless @supported
@@ -39,6 +41,7 @@ module ActiveSupport
@total = @data.threads.sum(0) { |thread| thread.methods.max.total_time }
end
+ remove_method :record
def record
return unless @supported
@@ -78,6 +81,7 @@ module ActiveSupport
self.class::Mode
end
+ remove_method :profile
def profile
RubyProf.resume
yield
@@ -86,6 +90,7 @@ module ActiveSupport
end
protected
+ remove_method :with_gc_stats
def with_gc_stats
GC::Profiler.enable
GC.start