Class: Decidim::AdminFiltersRegistry
- Inherits:
-
Object
- Object
- Decidim::AdminFiltersRegistry
- Defined in:
- decidim-core/lib/decidim/admin_filters_registry.rb
Overview
This class handles all logic regarding registering filters
Instance Attribute Summary collapse
-
#configurations ⇒ Object
readonly
Returns the value of attribute configurations.
Class Method Summary collapse
-
.create(name) ⇒ Object
Creates an empty named filter.
-
.find(name) ⇒ Object
Finds a filter by name.
-
.register(name, &block) ⇒ Object
Finds a filter by name or creates it if it does not exist.
Instance Method Summary collapse
-
#initialize ⇒ AdminFiltersRegistry
constructor
A new instance of AdminFiltersRegistry.
Constructor Details
#initialize ⇒ AdminFiltersRegistry
Returns a new instance of AdminFiltersRegistry.
51 52 53 |
# File 'decidim-core/lib/decidim/admin_filters_registry.rb', line 51 def initialize @configurations = [] end |
Instance Attribute Details
#configurations ⇒ Object (readonly)
Returns the value of attribute configurations.
49 50 51 |
# File 'decidim-core/lib/decidim/admin_filters_registry.rb', line 49 def configurations @configurations end |
Class Method Details
.create(name) ⇒ Object
Creates an empty named filter
38 39 40 |
# File 'decidim-core/lib/decidim/admin_filters_registry.rb', line 38 def create(name) all[name] = new end |
.find(name) ⇒ Object
Finds a filter by name
29 30 31 |
# File 'decidim-core/lib/decidim/admin_filters_registry.rb', line 29 def find(name) all[name] end |
.register(name, &block) ⇒ Object
Finds a filter by name or creates it if it does not exist.
16 17 18 19 20 21 22 |
# File 'decidim-core/lib/decidim/admin_filters_registry.rb', line 16 def register(name, &block) filter = find(name) || create(name) filter.configurations << block filter end |