Sha256: bd3bc6e3bdfe93f207fea2327f06021737e5abf434d196c5af9228cd31eea434
Contents?: true
Size: 760 Bytes
Versions: 3
Compression:
Stored size: 760 Bytes
Contents
# @!visibility private class Datagrid::Filters::ExtendedBooleanFilter < Datagrid::Filters::EnumFilter YES = "YES" NO = "NO" def initialize(report, attribute, options = {}, &block) options[:select] = -> { boolean_select } super(report, attribute, options, &block) end def execute(value, scope, grid_object) value = value.blank? ? nil : ::Datagrid::Utils.booleanize(value) super(value, scope, grid_object) end def parse(value) case when value == true YES when value == false NO when value.blank? nil else super(value) end end protected def boolean_select [YES, NO].map do |key, value| [I18n.t("datagrid.filters.xboolean.#{key.downcase}"), key] end end end
Version data entries
3 entries across 3 versions & 1 rubygems