class Datagrid::Filters::ExtendedBooleanFilter
Constants
- FALSE_VALUES
- NO
- TRUTH_VALUES
- YES
Public Class Methods
Source
# File lib/datagrid/filters/extended_boolean_filter.rb, line 11 def initialize(*args, **options) options[:select] = -> { boolean_select } super end
Calls superclass method
Datagrid::Filters::EnumFilter::new
Public Instance Methods
Source
# File lib/datagrid/filters/extended_boolean_filter.rb, line 21 def default_input_options { **super, type: "select" } end
Calls superclass method
Datagrid::Filters::EnumFilter#default_input_options
Source
# File lib/datagrid/filters/extended_boolean_filter.rb, line 16 def execute(value, scope, grid_object) value = value.blank? ? nil : ::Datagrid::Utils.booleanize(value) super end
Calls superclass method
Datagrid::Filters::BaseFilter#execute
Source
# File lib/datagrid/filters/extended_boolean_filter.rb, line 25 def parse(value) value = value.downcase if value.is_a?(String) case value when *TRUTH_VALUES YES when *FALSE_VALUES NO when value.blank? nil else super end end
Calls superclass method
Datagrid::Filters::EnumFilter#parse
Protected Instance Methods
Source
# File lib/datagrid/filters/extended_boolean_filter.rb, line 41 def boolean_select [YES, NO].map do |key, _value| [I18n.t("datagrid.filters.xboolean.#{key.downcase}"), key] end end