Sha256: 142e694cce7140edff4a7c6d36e14915f40d25f60c431d0ef46603ee7051f8fb

Contents?: true

Size: 546 Bytes

Versions: 44

Compression:

Stored size: 546 Bytes

Contents

require "datagrid/filters/select_options"

class Datagrid::Filters::EnumFilter < Datagrid::Filters::BaseFilter

  include Datagrid::Filters::SelectOptions

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

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

  def strict
    options[:strict]
  end

  def checkboxes?
    options[:checkboxes]
  end

end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
datagrid-1.8.2 lib/datagrid/filters/enum_filter.rb
datagrid-1.8.1 lib/datagrid/filters/enum_filter.rb
datagrid-1.8.0 lib/datagrid/filters/enum_filter.rb
datagrid-1.7.0 lib/datagrid/filters/enum_filter.rb
datagrid-1.6.3 lib/datagrid/filters/enum_filter.rb
datagrid-1.6.2 lib/datagrid/filters/enum_filter.rb
datagrid-1.6.1 lib/datagrid/filters/enum_filter.rb
datagrid-1.6.0 lib/datagrid/filters/enum_filter.rb
datagrid-1.5.9 lib/datagrid/filters/enum_filter.rb
datagrid-1.5.8 lib/datagrid/filters/enum_filter.rb
datagrid-1.5.7 lib/datagrid/filters/enum_filter.rb
datagrid-1.5.6 lib/datagrid/filters/enum_filter.rb
datagrid-1.5.5 lib/datagrid/filters/enum_filter.rb
datagrid-1.5.4 lib/datagrid/filters/enum_filter.rb
datagrid-1.5.3 lib/datagrid/filters/enum_filter.rb
datagrid-1.5.2 lib/datagrid/filters/enum_filter.rb
datagrid-1.5.1 lib/datagrid/filters/enum_filter.rb
datagrid-1.5.0 lib/datagrid/filters/enum_filter.rb
datagrid-1.4.4 lib/datagrid/filters/enum_filter.rb
datagrid-1.4.3 lib/datagrid/filters/enum_filter.rb