111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/mighty_grid/filters.rb', line 111
def filter(name, type = :string, options = {}, &block)
name = name.to_sym
unless self.mappings.key?(type)
fail MightyGrid::Exceptions::ArgumentError.new("filter for the specified type isn't supported.")
end
if name.present? && self.filters.key?(name)
fail MightyGrid::Exceptions::ArgumentError.new("filter with the specified name already exists.")
else
options.merge!(name: name)
options.merge!(model: @klass) unless options.key?(:model)
self.filters[name] = self.mappings[type].new(options, &block)
end
end
|