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: Injects the current feature into the environment.
Constructor Details
#initialize(manifest) ⇒ CurrentFeature
Public: Initializes the class.
manifest - The manifest of the feature to check against.
9 10 11 |
# File 'app/constraints/decidim/current_feature.rb', line 9 def initialize(manifest) @manifest = manifest end |
Instance Method Details
#matches?(request) ⇒ Boolean
Public: Injects the current feature into the environment.
request - The request that holds the current feature relevant
information.
Returns nothing.
19 20 21 22 23 24 25 26 |
# File 'app/constraints/decidim/current_feature.rb', line 19 def matches?(request) feature = detect_current_feature(request) return false unless feature request.env["decidim.current_participatory_process"] ||= feature.participatory_process request.env["decidim.current_feature"] ||= feature true end |