1
0
Fork 0
mirror of https://github.com/activerecord-hackery/ransack.git synced 2022-11-09 13:47:45 -05:00

Avoid ternaries & end-of-line conditionals

to keep conditionals explicit and painful.
This commit is contained in:
jonatack 2015-01-21 16:16:05 +01:00
parent 4018ac0053
commit c2345e4706

View file

@ -123,9 +123,11 @@ module Ransack
end
def value
predicate.wants_array ?
values.map { |v| v.cast(default_type) } :
if predicate.wants_array
values.map { |v| v.cast(default_type) }
else
values.first.cast(default_type)
end
end
def build(params)
@ -184,8 +186,9 @@ module Ransack
def formatted_values_for_attribute(attr)
formatted = casted_values_for_attribute(attr).map do |val|
val = attr.ransacker.formatter.call(val) if
attr.ransacker && attr.ransacker.formatter
if attr.ransacker && attr.ransacker.formatter
val = attr.ransacker.formatter.call(val)
end
val = predicate.format(val)
val
end