Class: Datagrid::Filters::EnumFilter

Inherits:
BaseFilter show all
Includes:
SelectOptions
Defined in:
lib/datagrid/filters/enum_filter.rb

Direct Known Subclasses

BooleanEnumFilter, ExtendedBooleanFilter

Instance Attribute Summary

Attributes inherited from BaseFilter

#block, #grid_class, #name, #options

Instance Method Summary collapse

Methods included from SelectOptions

#include_blank, #prompt, #select

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, #multiple?, #parse_values, #separator, #supports_range?, #type, #unapplicable_value?

Constructor Details

#initialize(*args) ⇒ EnumFilter

Returns a new instance of EnumFilter.


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

def initialize(*args)
  super(*args)
  if checkboxes?
    options[:multiple] = true
  end
  raise Datagrid::ConfigurationError, ":select option not specified" unless options[:select]
end

Instance Method Details

#checkboxes?Boolean

Returns:

  • (Boolean)

24
25
26
# File 'lib/datagrid/filters/enum_filter.rb', line 24

def checkboxes?
  options[:checkboxes]
end

#parse(value) ⇒ Object


15
16
17
18
# File 'lib/datagrid/filters/enum_filter.rb', line 15

def parse(value)
  return nil if self.strict && !select.include?(value)
  value
end

#strictObject


20
21
22
# File 'lib/datagrid/filters/enum_filter.rb', line 20

def strict
  options[:strict]
end