Class: Admin::Base::Resource::FiltersBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/admin/base/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFiltersBuilder

Returns a new instance of FiltersBuilder.



318
319
320
# File 'lib/admin/base/resource.rb', line 318

def initialize
  @filters = []
end

Instance Attribute Details

#filtersObject (readonly)

Returns the value of attribute filters.



316
317
318
# File 'lib/admin/base/resource.rb', line 316

def filters
  @filters
end

Instance Method Details

#filter(name, **options) ⇒ Object



322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/admin/base/resource.rb', line 322

def filter(name, **options)
  select_options = options.key?(:options) ? options[:options] : options[:collection]
  @filters << FilterDefinition.new(
    name: name,
    type: options[:type] || :text,
    label: options[:label] || name.to_s.humanize,
    placeholder: options[:placeholder],
    options: select_options,
    field: options[:field] || name,
    apply: options[:apply]
  )
end