Module: ActiveRecord::ValidationRecursionControl
- Defined in:
- lib/active_record/validation_recursion_control.rb
Overview
:nodoc:
Class Method Summary collapse
Instance Method Summary collapse
-
#valid_with_recursion_control?(*args, &block) ⇒ Boolean
It’s easy to break out of circular validation dependencies.
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 |
# File 'lib/active_record/validation_recursion_control.rb', line 3 def self.included(base) base.class_eval do alias_method_chain :valid?, :recursion_control end end |
Instance Method Details
#valid_with_recursion_control?(*args, &block) ⇒ Boolean
It’s easy to break out of circular validation dependencies. All we need to do is suppose that if a record’s validity depends in some way on itself, then we can assume that circular condition is satisfied. That assumption will change nothing about the actual validity of the record.
13 14 15 |
# File 'lib/active_record/validation_recursion_control.rb', line 13 def valid_with_recursion_control?(*args, &block) assumed_valid? or with_recursion_control do valid_without_recursion_control?(*args, &block) end end |