Class: Decidim::DecidimAwesome::ContextAnalyzers::RequestAnalyzer
- Inherits:
-
Object
- Object
- Decidim::DecidimAwesome::ContextAnalyzers::RequestAnalyzer
- Defined in:
- lib/decidim/decidim_awesome/context_analyzers/request_analyzer.rb
Overview
Translates some Decidim URL path to detected participatory spaces and components
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Class Method Summary collapse
Instance Method Summary collapse
- #extract_context! ⇒ Object
-
#initialize(request) ⇒ RequestAnalyzer
constructor
A new instance of RequestAnalyzer.
Constructor Details
#initialize(request) ⇒ RequestAnalyzer
Returns a new instance of RequestAnalyzer.
8 9 10 11 |
# File 'lib/decidim/decidim_awesome/context_analyzers/request_analyzer.rb', line 8 def initialize(request) @request = request @context = {} end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
19 20 21 |
# File 'lib/decidim/decidim_awesome/context_analyzers/request_analyzer.rb', line 19 def context @context end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
19 20 21 |
# File 'lib/decidim/decidim_awesome/context_analyzers/request_analyzer.rb', line 19 def request @request end |
Class Method Details
.context_for(request) ⇒ Object
13 14 15 16 17 |
# File 'lib/decidim/decidim_awesome/context_analyzers/request_analyzer.rb', line 13 def self.context_for(request) analyzer = new request analyzer.extract_context! analyzer.context end |
Instance Method Details
#extract_context! ⇒ Object
21 22 23 24 |
# File 'lib/decidim/decidim_awesome/context_analyzers/request_analyzer.rb', line 21 def extract_context! path = URI.parse(@request.url).path context_from_path path end |