diff options
author | Xavier Noria <fxn@hashref.com> | 2016-07-22 23:13:42 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2016-07-22 23:13:49 +0200 |
commit | cfc91c31aa989826e992be29b6d5b181f654f853 (patch) | |
tree | b5ec5569b22f8c796de89335c5ecc7de047130bc /activesupport/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb | |
parent | aea0e5cd709e0fc53e1ba4e87235b8ee3f4bc155 (diff) | |
download | rails-cfc91c31aa989826e992be29b6d5b181f654f853.tar.gz rails-cfc91c31aa989826e992be29b6d5b181f654f853.tar.bz2 rails-cfc91c31aa989826e992be29b6d5b181f654f853.zip |
systematic revision of =~ usage in AS
Where appropriate prefer the more concise Regexp#match?, String#include?,
String#start_with?, and String#end_with?
Diffstat (limited to 'activesupport/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb b/activesupport/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb index 045668c207..7015333f7c 100644 --- a/activesupport/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +++ b/activesupport/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb @@ -1,9 +1,10 @@ require 'active_support/core_ext/array/extract_options' +require 'active_support/core_ext/regexp' # Extends the module object with class/module and instance accessors for # class/module attributes, just like the native attr* accessors for instance # attributes, but does so on a per-thread basis. -# +# # So the values are scoped within the Thread.current space under the class name # of the module. class Module @@ -37,7 +38,7 @@ class Module options = syms.extract_options! syms.each do |sym| - raise NameError.new("invalid attribute name: #{sym}") unless sym =~ /^[_A-Za-z]\w*$/ + raise NameError.new("invalid attribute name: #{sym}") unless /^[_A-Za-z]\w*$/.match?(sym) class_eval(<<-EOS, __FILE__, __LINE__ + 1) def self.#{sym} Thread.current[:"attr_#{name}_#{sym}"] @@ -76,7 +77,7 @@ class Module def thread_mattr_writer(*syms) options = syms.extract_options! syms.each do |sym| - raise NameError.new("invalid attribute name: #{sym}") unless sym =~ /^[_A-Za-z]\w*$/ + raise NameError.new("invalid attribute name: #{sym}") unless /^[_A-Za-z]\w*$/.match?(sym) class_eval(<<-EOS, __FILE__, __LINE__ + 1) def self.#{sym}=(obj) Thread.current[:"attr_#{name}_#{sym}"] = obj |