Module: ActiveModel::Validations::Callbacks::ClassMethods
- Defined in:
- activemodel/lib/active_model/validations/callbacks.rb
Instance Method Summary collapse
Instance Method Details
#after_validation(*args, &block) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'activemodel/lib/active_model/validations/callbacks.rb', line 39 def after_validation(*args, &block) = args. [:prepend] = true [:if] = Array.wrap([:if]) [:if] << "!halted" [:if].unshift("self.validation_context == :#{[:on]}") if [:on] set_callback(:validation, :after, *(args << ), &block) end |
#before_validation(*args, &block) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'activemodel/lib/active_model/validations/callbacks.rb', line 30 def before_validation(*args, &block) = args.last if .is_a?(Hash) && [:on] [:if] = Array.wrap([:if]) [:if].unshift("self.validation_context == :#{[:on]}") end set_callback(:validation, :before, *args, &block) end |