Module: Ripple::Callbacks::ClassMethods
- Defined in:
- lib/ripple/callbacks.rb
Instance Method Summary collapse
-
#after_validation(*args, &block) ⇒ Object
Defines a callback to be run after validations.
-
#before_validation(*args, &block) ⇒ Object
Defines a callback to be run before validations.
Instance Method Details
#after_validation(*args, &block) ⇒ Object
Defines a callback to be run after validations.
30 31 32 33 34 35 36 37 |
# File 'lib/ripple/callbacks.rb', line 30 def after_validation(*args, &block) = args. [:prepend] = true [:if] = Array([:if]) [:if] << "!halted && value != false" [:if] << "@_on_validate == :#{[:on]}" if [:on] set_callback(:validation, :after, *(args << ), &block) end |
#before_validation(*args, &block) ⇒ Object
Defines a callback to be run before validations.
20 21 22 23 24 25 26 27 |
# File 'lib/ripple/callbacks.rb', line 20 def before_validation(*args, &block) = args.last if .is_a?(Hash) && [:on] [:if] = Array([:if]) [:if] << "@_on_validate == :#{[:on]}" end set_callback(:validation, :before, *args, &block) end |