diff options
author | Prem Sichanugrist <s@sikachu.com> | 2011-04-11 00:52:42 +0800 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2011-04-11 03:17:09 +0800 |
commit | a9f3c9da01d721963d05949604ead909aaabbf36 (patch) | |
tree | 5e278655997e1dcf86d9e0ee2f6be30d323fc8b4 /activemodel | |
parent | 635d991683c439da56fa72853880e88e6ac291ed (diff) | |
download | rails-a9f3c9da01d721963d05949604ead909aaabbf36.tar.gz rails-a9f3c9da01d721963d05949604ead909aaabbf36.tar.bz2 rails-a9f3c9da01d721963d05949604ead909aaabbf36.zip |
Using Object#in? and Object#either? in various places
There're a lot of places in Rails source code which make a lot of sense to switching to Object#in? or Object#either? instead of using [].include?.
Diffstat (limited to 'activemodel')
-rw-r--r-- | activemodel/lib/active_model/validator.rb | 3 | ||||
-rw-r--r-- | activemodel/test/cases/mass_assignment_security/sanitizer_test.rb | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb index c5ed8d22d3..64fe99b62d 100644 --- a/activemodel/lib/active_model/validator.rb +++ b/activemodel/lib/active_model/validator.rb @@ -1,6 +1,7 @@ require 'active_support/core_ext/array/wrap' require "active_support/core_ext/module/anonymous" require 'active_support/core_ext/object/blank' +require 'active_support/core_ext/object/inclusion' module ActiveModel #:nodoc: @@ -67,7 +68,7 @@ module ActiveModel #:nodoc: # # class TitleValidator < ActiveModel::EachValidator # def validate_each(record, attribute, value) - # record.errors[attribute] << 'must be Mr. Mrs. or Dr.' unless ['Mr.', 'Mrs.', 'Dr.'].include?(value) + # record.errors[attribute] << 'must be Mr. Mrs. or Dr.' unless value.either?('Mr.', 'Mrs.', 'Dr.') # end # end # diff --git a/activemodel/test/cases/mass_assignment_security/sanitizer_test.rb b/activemodel/test/cases/mass_assignment_security/sanitizer_test.rb index 015153ec7c..9a73a5ad91 100644 --- a/activemodel/test/cases/mass_assignment_security/sanitizer_test.rb +++ b/activemodel/test/cases/mass_assignment_security/sanitizer_test.rb @@ -1,5 +1,6 @@ require "cases/helper" require 'logger' +require 'active_support/core_ext/object/inclusion' class SanitizerTest < ActiveModel::TestCase @@ -9,7 +10,7 @@ class SanitizerTest < ActiveModel::TestCase attr_accessor :logger def deny?(key) - [ 'admin' ].include?(key) + key.in?(['admin']) end end |