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
1 changed files with 7 additions and 4 deletions

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