Class: Decidim::CurrentComponent
- Inherits:
- 
      Object
      
        - Object
- Decidim::CurrentComponent
 
- Defined in:
- app/constraints/decidim/current_component.rb
Overview
This class infers the current component we are scoped to by looking at the 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.
| 10 11 12 | # File 'app/constraints/decidim/current_component.rb', line 10 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 matched, false otherwise
| 20 21 22 23 24 25 26 27 | # File 'app/constraints/decidim/current_component.rb', line 20 def matches?(request) env = request.env @participatory_space = env["decidim.current_participatory_space"] return false unless @participatory_space current_component(env, request.params) ? true : false end |