Sha256: 896fd8ddd4b75d6b648cff5b0abb975164f9607c3e18b9d1af3b3b35d2fe3334

Contents?: true

Size: 451 Bytes

Versions: 10

Compression:

Stored size: 451 Bytes

Contents

class Datagrid::Filters::BooleanEnumFilter < Datagrid::Filters::EnumFilter

  YES = "YES"
  NO = "NO"
  VALUES = ActiveSupport::OrderedHash.new
  VALUES[YES] = YES
  VALUES[NO] = NO

  def initialize(report, attribute, options = {}, &block)
    options[:select] = VALUES.keys
    super(report, attribute, options, &block)
  end

  def apply(scope, value)
    super(scope, to_boolean(value))
  end

  def to_boolean(value)
    VALUES[value]
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
datagrid-0.5.4 lib/datagrid/filters/boolean_enum_filter.rb
datagrid-0.5.3 lib/datagrid/filters/boolean_enum_filter.rb
datagrid-0.5.2 lib/datagrid/filters/boolean_enum_filter.rb
datagrid-0.5.1 lib/datagrid/filters/boolean_enum_filter.rb
datagrid-0.5.0 lib/datagrid/filters/boolean_enum_filter.rb
datagrid-0.4.1 lib/datagrid/filters/boolean_enum_filter.rb
datagrid-0.4.0 lib/datagrid/filters/boolean_enum_filter.rb
datagrid-0.3.6 lib/datagrid/filters/boolean_enum_filter.rb
datagrid-0.3.5 lib/datagrid/filters/boolean_enum_filter.rb
datagrid-0.3.4 lib/datagrid/filters/boolean_enum_filter.rb