Class: Decidim::Consultations::CurrentComponent
- Inherits:
-
Object
- Object
- Decidim::Consultations::CurrentComponent
- Defined in:
- app/constraints/decidim/consultations/current_component.rb
Overview
This class infers the current component on an consultation context request parameters and injects it into the environment.
Instance Method Summary collapse
-
#initialize(manifest) ⇒ CurrentComponent
constructor
Public: Initializes the class.
-
#matches?(request) ⇒ Boolean
Public: Matches the request against a component and injects it into the environment.
Constructor Details
#initialize(manifest) ⇒ CurrentComponent
Public: Initializes the class.
manifest - The manifest of the component to check against.
11 12 13 |
# File 'app/constraints/decidim/consultations/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 a consultation and a component belonging to that consultation, false otherwise
22 23 24 25 |
# File 'app/constraints/decidim/consultations/current_component.rb', line 22 def matches?(request) CurrentQuestion.new.matches?(request) && Decidim::CurrentComponent.new(@manifest).matches?(request) end |