Module: Armada::Callbacks::ClassMethods

Defined in:
lib/armada/callbacks.rb

Instance Method Summary collapse

Instance Method Details

#after_validation(*args, &block) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/armada/callbacks.rb', line 34

def after_validation(*args, &block)
  options = args.extract_options!
  options[:prepend] = true
  options[:if] = Array(options[:if])
  options[:if] << "!halted && value != false"
  options[:if] << "@_on_validate == :#{options[:on]}" if options[:on]
  set_callback(:validation, :after, *(args << options), &block)
end

#before_validation(*args, &block) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/armada/callbacks.rb', line 25

def before_validation(*args, &block)
  options = args.last
  if options.is_a?(Hash) && options[:on]
    options[:if] = Array(options[:if])
    options[:if] << "@_on_validate == :#{options[:on]}"
  end
  set_callback(:validation, :before, *args, &block)
end