Method: ActiveScaffold::Finder::ClassMethods#condition_value_for_numeric

Defined in:
lib/active_scaffold/finder.rb

#condition_value_for_numeric(column, value) ⇒ Object



338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# File 'lib/active_scaffold/finder.rb', line 338

def condition_value_for_numeric(column, value)
  return value if value.nil?
  value = column.number_to_native(value) if column.options[:format] && column.search_ui != :number
  case (column.search_ui || column.column_type)
  when :integer   then
    if value.is_a?(TrueClass) || value.is_a?(FalseClass)
      value ? 1 : 0
    else
      value.to_i
    end
  when :float     then value.to_f
  when :decimal   then ::ActiveRecord::Type::Decimal.new.cast(value)
  else
    value
  end
end