diff options
author | Akira Matsuda <ronnie@dio.jp> | 2016-12-19 18:41:09 +0900 |
---|---|---|
committer | Akira Matsuda <ronnie@dio.jp> | 2016-12-24 12:18:16 +0900 |
commit | cdb9d7f481a6b299cd53a0f647397da60d806a21 (patch) | |
tree | 44159052e42e6add9ed5f74870df8fbcc027caa8 /activemodel/lib/active_model/validations | |
parent | 53f537d1f83e48aa72ea9ecbf23cc3c7302758a6 (diff) | |
download | rails-cdb9d7f481a6b299cd53a0f647397da60d806a21.tar.gz rails-cdb9d7f481a6b299cd53a0f647397da60d806a21.tar.bz2 rails-cdb9d7f481a6b299cd53a0f647397da60d806a21.zip |
Privatize unneededly protected methods in Active Model
Diffstat (limited to 'activemodel/lib/active_model/validations')
-rw-r--r-- | activemodel/lib/active_model/validations/callbacks.rb | 4 | ||||
-rw-r--r-- | activemodel/lib/active_model/validations/numericality.rb | 22 | ||||
-rw-r--r-- | activemodel/lib/active_model/validations/validates.rb | 6 |
3 files changed, 15 insertions, 17 deletions
diff --git a/activemodel/lib/active_model/validations/callbacks.rb b/activemodel/lib/active_model/validations/callbacks.rb index a201f72ed0..70bc1a0624 100644 --- a/activemodel/lib/active_model/validations/callbacks.rb +++ b/activemodel/lib/active_model/validations/callbacks.rb @@ -104,10 +104,10 @@ module ActiveModel end end - protected + private # Overwrite run validations to include callbacks. - def run_validations! #:nodoc: + def run_validations! _run_validation_callbacks { super } end end diff --git a/activemodel/lib/active_model/validations/numericality.rb b/activemodel/lib/active_model/validations/numericality.rb index 48e0e5c9f6..2297faaee5 100644 --- a/activemodel/lib/active_model/validations/numericality.rb +++ b/activemodel/lib/active_model/validations/numericality.rb @@ -61,29 +61,29 @@ module ActiveModel end end - protected + private - def is_number?(raw_value) + def is_number?(raw_value) # :doc: !parse_raw_value_as_a_number(raw_value).nil? rescue ArgumentError, TypeError false end - def parse_raw_value_as_a_number(raw_value) + def parse_raw_value_as_a_number(raw_value) # :doc: Kernel.Float(raw_value) if raw_value !~ /\A0[xX]/ end - def is_integer?(raw_value) + def is_integer?(raw_value) # :doc: /\A[+-]?\d+\z/ === raw_value.to_s end - def filtered_options(value) + def filtered_options(value) # :doc: filtered = options.except(*RESERVED_OPTIONS) filtered[:value] = value filtered end - def allow_only_integer?(record) + def allow_only_integer?(record) # :doc: case options[:only_integer] when Symbol record.send(options[:only_integer]) @@ -94,12 +94,10 @@ module ActiveModel end end - private - - def record_attribute_changed_in_place?(record, attr_name) - record.respond_to?(:attribute_changed_in_place?) && - record.attribute_changed_in_place?(attr_name.to_s) - end + def record_attribute_changed_in_place?(record, attr_name) + record.respond_to?(:attribute_changed_in_place?) && + record.attribute_changed_in_place?(attr_name.to_s) + end end module HelperMethods diff --git a/activemodel/lib/active_model/validations/validates.rb b/activemodel/lib/active_model/validations/validates.rb index f95f44de61..0ce5935f3a 100644 --- a/activemodel/lib/active_model/validations/validates.rb +++ b/activemodel/lib/active_model/validations/validates.rb @@ -148,15 +148,15 @@ module ActiveModel validates(*(attributes << options)) end - protected + private # When creating custom validators, it might be useful to be able to specify # additional default keys. This can be done by overwriting this method. - def _validates_default_keys # :nodoc: + def _validates_default_keys [:if, :unless, :on, :allow_blank, :allow_nil , :strict] end - def _parse_validates_options(options) # :nodoc: + def _parse_validates_options(options) case options when TrueClass {} |