Module: ActiveModel::Warnings::ClassMethods

Defined in:
lib/activemodel-warnings.rb

Instance Method Summary collapse

Instance Method Details

#validate(*args, &block) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/activemodel-warnings.rb', line 22

def validate(*args, &block)
  options = args.extract_options!
  
  if options[:warning] || @warnings_block
    options = options.dup
    options[:warning] ||= @warnings_block
    options[:if] = Array.wrap(options[:if])
    options[:if] << "skip_warnings != true"
  end
  args << options

  super
end

#validates_with(*args, &block) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/activemodel-warnings.rb', line 36

def validates_with(*args, &block)
  options = args.extract_options!

  if options[:warning] || @warnings_block
    options = options.dup
    options[:warning] ||= @warnings_block
  end
  args << options
  super
end

#warningsObject



15
16
17
18
19
20
# File 'lib/activemodel-warnings.rb', line 15

def warnings()
  @warnings_block = true
  yield
ensure
  @warnings_block = false
end