Module: Datagrid::Filters::ClassMethods

Defined in:
lib/datagrid/filters.rb

Overview

self.included

Instance Method Summary collapse

Instance Method Details

#filter(attribute, *args, &block) ⇒ Object

Raises:



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/datagrid/filters.rb', line 49

def filter(attribute, *args, &block)
  options = args.extract_options!
  type = args.shift || :default

  klass = type.is_a?(Class) ? type : FILTER_TYPES[type]
  raise ConfigurationError, "filter class #{type.inspect} not found" unless klass


  filter = klass.new(self, attribute, options, &block)
  self.filters << filter

  datagrid_attribute(attribute) do |value|
    filter.parse_values(value)
  end

end

#filter_by_name(attribute) ⇒ Object



43
44
45
46
47
# File 'lib/datagrid/filters.rb', line 43

def filter_by_name(attribute)
  self.filters.find do |filter|
    filter.name.to_sym == attribute.to_sym
  end
end