Class: Decidim::FilterResource::Filter
- Inherits:
-
Object
- Object
- Decidim::FilterResource::Filter
- Defined in:
- decidim-core/app/controllers/concerns/decidim/filter_resource.rb
Overview
Internal: Defines a class that will wrap in an object the URL params used by the filter. this way we can use Rails’ form helpers and have automatically checked checkboxes and radio buttons in the view, for example.
Instance Method Summary collapse
-
#initialize(filter) ⇒ Filter
constructor
A new instance of Filter.
- #method_missing(method_name, *_arguments) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(filter) ⇒ Filter
Returns a new instance of Filter.
14 15 16 |
# File 'decidim-core/app/controllers/concerns/decidim/filter_resource.rb', line 14 def initialize(filter) @filter = filter end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *_arguments) ⇒ Object
18 19 20 21 |
# File 'decidim-core/app/controllers/concerns/decidim/filter_resource.rb', line 18 def method_missing(method_name, *_arguments) method = method_name.to_s.gsub(/\[[0-9]+\]$/, "").to_sym @filter.present? && @filter.has_key?(method) ? @filter[method] : super end |
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
23 24 25 26 |
# File 'decidim-core/app/controllers/concerns/decidim/filter_resource.rb', line 23 def respond_to_missing?(method_name, include_private = false) method = method_name.to_s.gsub(/\[[0-9]+\]$/, "").to_sym (@filter.present? && @filter.has_key?(method)) || super end |