Class: Decidim::AdminFiltersRegistry

Inherits:
Object
  • Object
show all
Defined in:
decidim-core/lib/decidim/admin_filters_registry.rb

Overview

This class handles all logic regarding registering filters

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAdminFiltersRegistry

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

#configurationsObject (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

Parameters:

  • name (Symbol)

    The name of the 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

Parameters:

  • name (Symbol)

    The name of the filter



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.

Parameters:

  • name (Symbol)

    Name of the filter

  • &block (Filter)

    Registration body of the filter. It is stored to be evaluated at rendering time



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