Class: Datagrid::Filters::IntegerFilter

Inherits:
BaseFilter
  • Object
show all
Includes:
RangedFilter
Defined in:
lib/datagrid/filters/integer_filter.rb

Instance Method Summary collapse

Methods included from RangedFilter

#default_filter_where, #initialize, #parse_values, #range?

Instance Method Details

#parse(value) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/datagrid/filters/integer_filter.rb', line 7

def parse(value)
  return nil if value.blank?
  if defined?(ActiveRecord) && value.is_a?(ActiveRecord::Base) &&
      value.respond_to?(:id) && value.id.is_a?(Integer)
    return value.id
  end
  return value if value.is_a?(Range)
  value.to_i
end