Module: ActiveModel::Validations::ResolveValue

Included in:
Clusivity, ComparisonValidator, FormatValidator, LengthValidator, NumericalityValidator
Defined in:
lib/active_model/validations/resolve_value.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#resolve_value(record, value) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/active_model/validations/resolve_value.rb', line 6

def resolve_value(record, value)
  case value
  when Proc
    if value.arity == 0
      value.call
    else
      value.call(record)
    end
  when Symbol
    record.send(value)
  else
    if value.respond_to?(:call)
      value.call(record)
    else
      value
    end
  end
end