public Method

ClassMethods.evaluate_condition(condition, record)

Determine from the given condition (whether a block, procedure, method or string) whether or not to validate the record. See #validates_each.

Source Code

# File active_record/validations.rb, line 348
def evaluate_condition(condition, record)
  case condition
    when Symbol; record.send(condition)
    when String; eval(condition, record.send(:binding))
    else
      if condition_block?(condition)
        condition.call(record)
      else
        raise(
          ActiveRecordError,
          "Validations need to be either a symbol, string (to be eval'ed), proc/method, or " +
          "class implementing a static validation method"
        )
      end
    end
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.