diff options
Diffstat (limited to 'activemodel/lib/active_model')
4 files changed, 5 insertions, 5 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index 42c004ce31..c91ac69603 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -100,7 +100,7 @@ module ActiveModel def copy!(other) # :nodoc: @errors = other.errors.deep_dup @errors.each { |error| - error.instance_variable_set("@base", @base) + error.instance_variable_set(:@base, @base) } end diff --git a/activemodel/lib/active_model/type/helpers/timezone.rb b/activemodel/lib/active_model/type/helpers/timezone.rb index cf87b9715b..b0477aec32 100644 --- a/activemodel/lib/active_model/type/helpers/timezone.rb +++ b/activemodel/lib/active_model/type/helpers/timezone.rb @@ -7,7 +7,7 @@ module ActiveModel module Helpers # :nodoc: all module Timezone def is_utc? - ::Time.zone_default.nil? || ::Time.zone_default =~ "UTC" + ::Time.zone_default.nil? || ::Time.zone_default.match?("UTC") end def default_timezone diff --git a/activemodel/lib/active_model/validations/format.rb b/activemodel/lib/active_model/validations/format.rb index bea57415b0..a473440b4e 100644 --- a/activemodel/lib/active_model/validations/format.rb +++ b/activemodel/lib/active_model/validations/format.rb @@ -6,7 +6,7 @@ module ActiveModel def validate_each(record, attribute, value) if options[:with] regexp = option_call(record, :with) - record_error(record, attribute, :with, value) if value.to_s !~ regexp + record_error(record, attribute, :with, value) unless regexp.match?(value.to_s) elsif options[:without] regexp = option_call(record, :without) record_error(record, attribute, :without, value) if regexp.match?(value.to_s) diff --git a/activemodel/lib/active_model/validations/validates.rb b/activemodel/lib/active_model/validations/validates.rb index 97612d474d..8906837aa8 100644 --- a/activemodel/lib/active_model/validations/validates.rb +++ b/activemodel/lib/active_model/validations/validates.rb @@ -27,7 +27,7 @@ module ActiveModel # class EmailValidator < ActiveModel::EachValidator # def validate_each(record, attribute, value) # record.errors.add attribute, (options[:message] || "is not an email") unless - # value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i + # /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i.match?(value) # end # end # @@ -47,7 +47,7 @@ module ActiveModel # # class TitleValidator < ActiveModel::EachValidator # def validate_each(record, attribute, value) - # record.errors.add attribute, "must start with 'the'" unless value =~ /\Athe/i + # record.errors.add attribute, "must start with 'the'" unless /\Athe/i.match?(value) # end # end # |