Method: ActiveScaffold::Finder::ClassMethods#condition_for_numeric

Defined in:
lib/active_scaffold/finder.rb

#condition_for_numeric(column, value) ⇒ Object



184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/active_scaffold/finder.rb', line 184

def condition_for_numeric(column, value)
  if !value.is_a?(Hash)
    ['%<search_sql>s = ?', condition_value_for_numeric(column, value)]
  elsif ActiveScaffold::Finder::NULL_COMPARATORS.include?(value[:opt])
    condition_for_null_type(column, value[:opt])
  elsif value[:from].blank? || !ActiveScaffold::Finder::NUMERIC_COMPARATORS.include?(value[:opt])
    nil
  elsif value[:opt] == 'BETWEEN'
    ['(%<search_sql>s BETWEEN ? AND ?)', condition_value_for_numeric(column, value[:from]), condition_value_for_numeric(column, value[:to])]
  else
    ["%<search_sql>s #{value[:opt]} ?", condition_value_for_numeric(column, value[:from])]
  end
end