Class: Decidim::CurrentFeature
- Inherits:
-
Object
- Object
- Decidim::CurrentFeature
- Defined in:
- app/constraints/decidim/current_feature.rb
Overview
This class infers the current feature we’re scoped to by looking at the request parameters and injects it into the environment.
Instance Method Summary collapse
-
#initialize(manifest) ⇒ CurrentFeature
constructor
Public: Initializes the class.
-
#matches?(request) ⇒ Boolean
Public: Matches the request against a feature and injects it into the environment.
Constructor Details
#initialize(manifest) ⇒ CurrentFeature
Public: Initializes the class.
manifest - The manifest of the feature to check against.
10 11 12 |
# File 'app/constraints/decidim/current_feature.rb', line 10 def initialize(manifest) @manifest = manifest end |
Instance Method Details
#matches?(request) ⇒ Boolean
Public: Matches the request against a feature and injects it into the
environment.
request - The request that holds the current feature relevant information.
Returns a true if the request matched, false otherwise
20 21 22 23 24 25 26 27 28 |
# File 'app/constraints/decidim/current_feature.rb', line 20 def matches?(request) env = request.env return false unless CurrentParticipatoryProcess.new.matches?(request) @participatory_process = env["decidim.current_participatory_process"] current_feature(env, request.params) ? true : false end |