aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/attribute_methods.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2016-07-24 21:23:23 +0200
committerXavier Noria <fxn@hashref.com>2016-07-24 21:23:23 +0200
commit5a83f054244288032a7c41c13c870674e61b14ae (patch)
tree2c8a54524901499b140c28d6e6abe1a85d7b6e76 /activemodel/lib/active_model/attribute_methods.rb
parent56527bb737eb5e1d5531cafe99ce91d025565ead (diff)
downloadrails-5a83f054244288032a7c41c13c870674e61b14ae.tar.gz
rails-5a83f054244288032a7c41c13c870674e61b14ae.tar.bz2
rails-5a83f054244288032a7c41c13c870674e61b14ae.zip
systematic revision of =~ usage in AMo
Diffstat (limited to 'activemodel/lib/active_model/attribute_methods.rb')
-rw-r--r--activemodel/lib/active_model/attribute_methods.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb
index cc6285f932..140eb9420e 100644
--- a/activemodel/lib/active_model/attribute_methods.rb
+++ b/activemodel/lib/active_model/attribute_methods.rb
@@ -1,5 +1,6 @@
require 'concurrent/map'
require 'mutex_m'
+require 'active_support/core_ext/regexp'
module ActiveModel
# Raised when an attribute is not defined.
@@ -366,7 +367,7 @@ module ActiveModel
# using the given `extra` args. This falls back on `define_method`
# and `send` if the given names cannot be compiled.
def define_proxy_call(include_private, mod, name, send, *extra) #:nodoc:
- defn = if name =~ NAME_COMPILABLE_REGEXP
+ defn = if NAME_COMPILABLE_REGEXP.match?(name)
"def #{name}(*args)"
else
"define_method(:'#{name}') do |*args|"
@@ -374,7 +375,7 @@ module ActiveModel
extra = (extra.map!(&:inspect) << "*args").join(", ".freeze)
- target = if send =~ CALL_COMPILABLE_REGEXP
+ target = if CALL_COMPILABLE_REGEXP.match?(send)
"#{"self." unless include_private}#{send}(#{extra})"
else
"send(:'#{send}', #{extra})"