From cb12e0408a88ca128da9c7a8a46ff4c75b0c4dd9 Mon Sep 17 00:00:00 2001 From: Steven Harman Date: Sun, 6 Apr 2014 22:06:18 -0400 Subject: Add documentation for Thread#freeze --- activesupport/lib/active_support/core_ext/thread.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/core_ext/thread.rb b/activesupport/lib/active_support/core_ext/thread.rb index ac1ffa4128..4cd6634558 100644 --- a/activesupport/lib/active_support/core_ext/thread.rb +++ b/activesupport/lib/active_support/core_ext/thread.rb @@ -62,6 +62,13 @@ class Thread _locals.has_key?(key.to_sym) end + # Freezes the thread so that thread local variables cannot be set via + # Thread#thread_variable_set, nor can fiber local variables be set. + # + # me = Thread.current + # me.freeze + # me.thread_variable_set(:oliver, "a") #=> RuntimeError: can't modify frozen thread locals + # me[:oliver] = "a" #=> RuntimeError: can't modify frozen thread locals def freeze _locals.freeze super -- cgit v1.2.3 From d870cfd981d017fb39ae805832cbef773e7abc02 Mon Sep 17 00:00:00 2001 From: Steven Harman Date: Fri, 11 Apr 2014 16:04:53 -0400 Subject: Document LoadError core extensions [ci skip] --- activesupport/lib/active_support/core_ext/load_error.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/core_ext/load_error.rb b/activesupport/lib/active_support/core_ext/load_error.rb index fe24f3716d..81eaee8ca3 100644 --- a/activesupport/lib/active_support/core_ext/load_error.rb +++ b/activesupport/lib/active_support/core_ext/load_error.rb @@ -7,6 +7,7 @@ class LoadError ] unless method_defined?(:path) + # Returns the path which was unable to be loaded. def path @path ||= begin REGEXPS.find do |regex| @@ -17,9 +18,11 @@ class LoadError end end + # Returns true if the given path name (except perhaps for the ".rb" + # extension) is the missing file which caused the exception to be raised. def is_missing?(location) location.sub(/\.rb$/, '') == path.sub(/\.rb$/, '') end end -MissingSourceFile = LoadError \ No newline at end of file +MissingSourceFile = LoadError -- cgit v1.2.3 From 7240d6a495122703f3120699707f93f90f612b4f Mon Sep 17 00:00:00 2001 From: Steven Harman Date: Fri, 11 Apr 2014 16:24:08 -0400 Subject: Correct docs as singlton true is not returned here [ci skip] --- activesupport/lib/active_support/core_ext/load_error.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/core_ext/load_error.rb b/activesupport/lib/active_support/core_ext/load_error.rb index 81eaee8ca3..768b980f21 100644 --- a/activesupport/lib/active_support/core_ext/load_error.rb +++ b/activesupport/lib/active_support/core_ext/load_error.rb @@ -18,7 +18,7 @@ class LoadError end end - # Returns true if the given path name (except perhaps for the ".rb" + # Returns true if the given path name (except perhaps for the ".rb" # extension) is the missing file which caused the exception to be raised. def is_missing?(location) location.sub(/\.rb$/, '') == path.sub(/\.rb$/, '') -- cgit v1.2.3