Class: Decidim::FilterResource::Filter

Inherits:
Object
  • Object
show all
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

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
# File 'decidim-core/app/controllers/concerns/decidim/filter_resource.rb', line 18

def method_missing(method_name, *_arguments)
  @filter.present? && @filter.has_key?(method_name) ? @filter[method_name] : super
end

Instance Method Details

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)

22
23
24
# File 'decidim-core/app/controllers/concerns/decidim/filter_resource.rb', line 22

def respond_to_missing?(method_name, include_private = false)
  @filter.present? && @filter.has_key?(method_name) || super
end