module UseCaseValidations::Validations

Active Model Length Validator

Active Model Numericality Validator

Public Instance Methods

similar_objects?(record, other_record, attribute) click to toggle source
# File lib/usecasing_validations/validations/uniqueness.rb, line 29
def similar_objects?(record, other_record, attribute)
  if options.key?(:conditions)
    if base.method(options[:conditions]).arity == 3
      base.send(options[:conditions], record, other_record, attribute)
    else
      base.send(options[:conditions], record, other_record)
    end
  else
    record.send(attribute) == other_record.send(attribute)
  end
end