Module: ActiveAdmin::ResourceController::Filters::ClassMethods
- Defined in:
- lib/active_admin/resource_controller/filters.rb
Instance Method Summary collapse
-
#default_association_filters ⇒ Object
Returns a default set of filters for the associations.
-
#default_content_filters ⇒ Object
Returns a default set of filters for the content columns.
-
#default_filters_config ⇒ Object
Returns a sane set of filters by default for the object.
- #filter(attribute, options = {}) ⇒ Object
- #filters_config ⇒ Object
- #reset_filters! ⇒ Object
Instance Method Details
#default_association_filters ⇒ Object
Returns a default set of filters for the associations
32 33 34 35 36 37 38 |
# File 'lib/active_admin/resource_controller/filters.rb', line 32 def default_association_filters if resource_class.respond_to?(:reflections) resource_class.reflections.collect{|name, r| { :attribute => name }} else [] end end |
#default_content_filters ⇒ Object
Returns a default set of filters for the content columns
41 42 43 44 45 46 47 |
# File 'lib/active_admin/resource_controller/filters.rb', line 41 def default_content_filters if resource_class.respond_to?(:content_columns) resource_class.content_columns.collect{|c| { :attribute => c.name.to_sym } } else [] end end |
#default_filters_config ⇒ Object
Returns a sane set of filters by default for the object
27 28 29 |
# File 'lib/active_admin/resource_controller/filters.rb', line 27 def default_filters_config default_association_filters + default_content_filters end |
#filter(attribute, options = {}) ⇒ Object
12 13 14 15 16 |
# File 'lib/active_admin/resource_controller/filters.rb', line 12 def filter(attribute, = {}) return false if attribute.nil? @filters ||= [] @filters << .merge(:attribute => attribute) end |
#filters_config ⇒ Object
18 19 20 |
# File 'lib/active_admin/resource_controller/filters.rb', line 18 def filters_config @filters && @filters.any? ? @filters : default_filters_config end |
#reset_filters! ⇒ Object
22 23 24 |
# File 'lib/active_admin/resource_controller/filters.rb', line 22 def reset_filters! @filters = [] end |