Class: Datagrid::Filters::IntegerFilter

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

Instance Attribute Summary

Attributes inherited from BaseFilter

#block, #grid_class, #name, #options

Instance Method Summary collapse

Methods included from RangedFilter

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

Methods inherited from BaseFilter

#allow_blank?, #allow_nil?, #apply, #default, #default_filter_block, #dummy?, #enabled?, form_builder_helper_name, #form_builder_helper_name, #format, #header, #initialize, #input_options, #label_options, #multiple?, #parse_values, #separator, #supports_range?, #type, #unapplicable_value?

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