Class: Decidim::Initiatives::CurrentComponent

Inherits:
Object
  • Object
show all
Defined in:
decidim-initiatives/app/constraints/decidim/initiatives/current_component.rb

Overview

This class infers the current component on an initiative context request parameters and injects it into the environment.

Instance Method Summary collapse

Constructor Details

#initialize(manifest) ⇒ CurrentComponent

Public: Initializes the class.

manifest - The manifest of the component to check against.


11
12
13
# File 'decidim-initiatives/app/constraints/decidim/initiatives/current_component.rb', line 11

def initialize(manifest)
  @manifest = manifest
end

Instance Method Details

#matches?(request) ⇒ Boolean

Public: Matches the request against a component and injects it into the

environment.

request - The request that holds the current component relevant information.

Returns a true if the request matches an initiative and a component belonging to that initiative, false otherwise

Returns:

  • (Boolean)

22
23
24
25
# File 'decidim-initiatives/app/constraints/decidim/initiatives/current_component.rb', line 22

def matches?(request)
  CurrentInitiative.new.matches?(request) &&
    Decidim::CurrentComponent.new(@manifest).matches?(request)
end