diff options
author | lvl0nax <lvl0nax@gmail.com> | 2016-04-28 15:18:51 +0300 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2016-04-29 13:43:15 -0700 |
commit | 517cf249c369d4bca40b1f590ca641d8b717985e (patch) | |
tree | 445acaf994f8ebed290ccee2bf14840b33dd1825 /activemodel/lib/active_model | |
parent | 3136b17b7f5c3acd52248c65ebbd9e2bfcf5ac19 (diff) | |
download | rails-517cf249c369d4bca40b1f590ca641d8b717985e.tar.gz rails-517cf249c369d4bca40b1f590ca641d8b717985e.tar.bz2 rails-517cf249c369d4bca40b1f590ca641d8b717985e.zip |
Chomp: prefer String#chomp where we can for a clarity boost
Closes #24766, #24767
Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r-- | activemodel/lib/active_model/validations/acceptance.rb | 6 | ||||
-rw-r--r-- | activemodel/lib/active_model/validator.rb | 2 |
2 files changed, 2 insertions, 6 deletions
diff --git a/activemodel/lib/active_model/validations/acceptance.rb b/activemodel/lib/active_model/validations/acceptance.rb index c5c0cd4636..a04e5f347e 100644 --- a/activemodel/lib/active_model/validations/acceptance.rb +++ b/activemodel/lib/active_model/validations/acceptance.rb @@ -64,11 +64,7 @@ module ActiveModel private def convert_to_reader_name(method_name) - attr_name = method_name.to_s - if attr_name.end_with?("=") - attr_name = attr_name[0..-2] - end - attr_name + method_name.to_s.chomp('=') end end end diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb index 109bf038b0..699f74ed17 100644 --- a/activemodel/lib/active_model/validator.rb +++ b/activemodel/lib/active_model/validator.rb @@ -100,7 +100,7 @@ module ActiveModel # PresenceValidator.kind # => :presence # UniquenessValidator.kind # => :uniqueness def self.kind - @kind ||= name.split('::').last.underscore.sub(/_validator$/, '').to_sym unless anonymous? + @kind ||= name.split('::').last.underscore.chomp('_validator').to_sym unless anonymous? end # Accepts options that will be made available through the +options+ reader. |