1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activemodel/lib/active_model/validations/comparability.rb
Rafael Mendonça França 18707ab17f
Standardize nodoc comments
2021-07-29 21:18:07 +00:00

29 lines
710 B
Ruby

# frozen_string_literal: true
module ActiveModel
module Validations
module Comparability # :nodoc:
COMPARE_CHECKS = { greater_than: :>, greater_than_or_equal_to: :>=,
equal_to: :==, less_than: :<, less_than_or_equal_to: :<=,
other_than: :!= }.freeze
def option_value(record, option_value)
case option_value
when Proc
option_value.call(record)
when Symbol
record.send(option_value)
else
option_value
end
end
def error_options(value, option_value)
options.except(*COMPARE_CHECKS.keys).merge!(
count: option_value,
value: value
)
end
end
end
end