Sha256: d7890a1858351e0ba7f831c63ad9d012e080c250a47a86c232cb94fff24d607a

Contents?: true

Size: 495 Bytes

Versions: 9

Compression:

Stored size: 495 Bytes

Contents

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

  def initialize(*args)
    super(*args)
    raise Datagrid::ConfigurationError, ":select option not specified" unless select
  end

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

  def select
    self.options[:select]
  end


  def include_blank
    self.options.has_key?(:include_blank) ? options[:include_blank] : true
  end

  def strict
    self.options[:strict]
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
datagrid-0.3.4 lib/datagrid/filters/enum_filter.rb
datagrid-0.3.3 lib/datagrid/filters/enum_filter.rb
datagrid-0.3.2 lib/datagrid/filters/enum_filter.rb
datagrid-0.3.1 lib/datagrid/filters/enum_filter.rb
datagrid-0.3.0 lib/datagrid/filters/enum_filter.rb
datagrid-0.2.0 lib/datagrid/filters/enum_filter.rb
datagrid-0.1.2 lib/datagrid/filters/enum_filter.rb
datagrid-0.1.1 lib/datagrid/filters/enum_filter.rb
datagrid-0.1.0 lib/datagrid/filters/enum_filter.rb