Module: ActiveAdmin::Filters::ResourceExtension
- Defined in:
- lib/active_admin/filters/resource_extension.rb
Instance Method Summary collapse
-
#add_filter(attribute, options = {}) ⇒ Object
Add a filter for this resource.
-
#current_filters=(bool) ⇒ Object
Setter to enable/disable showing current filters on this resource.
-
#current_filters_enabled? ⇒ Boolean
If show current filters are enabled for this resource.
-
#filters ⇒ Hash
Returns the filters for this resource.
-
#filters=(bool) ⇒ Object
Setter to enable / disable filters on this resource.
-
#filters_enabled? ⇒ Boolean
If filters are enabled for this resource.
- #initialize ⇒ Object
- #preserve_default_filters! ⇒ Object
- #preserve_default_filters? ⇒ Boolean
-
#remove_filter(*attributes) ⇒ Object
Remove a filter for this resource.
-
#reset_filters! ⇒ Object
Reset the filters to use defaults.
Instance Method Details
#add_filter(attribute, options = {}) ⇒ Object
Add a filter for this resource. If filters are not enabled, this method will raise a RuntimeError
74 75 76 77 78 |
# File 'lib/active_admin/filters/resource_extension.rb', line 74 def add_filter(attribute, = {}) raise Disabled unless filters_enabled? (@filters ||= {})[attribute.to_sym] = end |
#current_filters=(bool) ⇒ Object
Setter to enable/disable showing current filters on this resource.
Set to ‘nil` to inherit the setting from the namespace
36 37 38 |
# File 'lib/active_admin/filters/resource_extension.rb', line 36 def current_filters=(bool) @current_filters_enabled = bool end |
#current_filters_enabled? ⇒ Boolean
Returns If show current filters are enabled for this resource.
46 47 48 |
# File 'lib/active_admin/filters/resource_extension.rb', line 46 def current_filters_enabled? @current_filters_enabled.nil? ? namespace.current_filters : @current_filters_enabled end |
#filters ⇒ Hash
Returns the filters for this resource. If filters are not enabled, it will always return an empty hash.
22 23 24 |
# File 'lib/active_admin/filters/resource_extension.rb', line 22 def filters filters_enabled? ? filter_lookup : {} end |
#filters=(bool) ⇒ Object
Setter to enable / disable filters on this resource.
Set to ‘nil` to inherit the setting from the namespace
29 30 31 |
# File 'lib/active_admin/filters/resource_extension.rb', line 29 def filters=(bool) @filters_enabled = bool end |
#filters_enabled? ⇒ Boolean
Returns If filters are enabled for this resource.
41 42 43 |
# File 'lib/active_admin/filters/resource_extension.rb', line 41 def filters_enabled? @filters_enabled.nil? ? namespace.filters : @filters_enabled end |
#initialize ⇒ Object
12 13 14 15 16 |
# File 'lib/active_admin/filters/resource_extension.rb', line 12 def initialize(*) super end |
#preserve_default_filters! ⇒ Object
50 51 52 |
# File 'lib/active_admin/filters/resource_extension.rb', line 50 def preserve_default_filters! @preserve_default_filters = true end |
#preserve_default_filters? ⇒ Boolean
54 55 56 |
# File 'lib/active_admin/filters/resource_extension.rb', line 54 def preserve_default_filters? @preserve_default_filters == true end |
#remove_filter(*attributes) ⇒ Object
Remove a filter for this resource. If filters are not enabled, this method will raise a RuntimeError
62 63 64 65 66 |
# File 'lib/active_admin/filters/resource_extension.rb', line 62 def remove_filter(*attributes) raise Disabled unless filters_enabled? attributes.each { |attribute| (@filters_to_remove ||= []) << attribute.to_sym } end |
#reset_filters! ⇒ Object
Reset the filters to use defaults
81 82 83 84 |
# File 'lib/active_admin/filters/resource_extension.rb', line 81 def reset_filters! @filters = nil @filters_to_remove = nil end |