Class: Decidim::DecidimAwesome::ContextAnalyzers::ParticipatorySpaceAnalyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/decidim/decidim_awesome/context_analyzers/participatory_space_analyzer.rb

Overview

Translates a decidim participatory_space to detected participatory spaces

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(participatory_space) ⇒ ParticipatorySpaceAnalyzer

Returns a new instance of ParticipatorySpaceAnalyzer.



8
9
10
11
# File 'lib/decidim/decidim_awesome/context_analyzers/participatory_space_analyzer.rb', line 8

def initialize(participatory_space)
  @participatory_space = participatory_space
  @context = {}
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



19
20
21
# File 'lib/decidim/decidim_awesome/context_analyzers/participatory_space_analyzer.rb', line 19

def context
  @context
end

#participatory_spaceObject (readonly)

Returns the value of attribute participatory_space.



19
20
21
# File 'lib/decidim/decidim_awesome/context_analyzers/participatory_space_analyzer.rb', line 19

def participatory_space
  @participatory_space
end

Class Method Details

.context_for(participatory_space) ⇒ Object



13
14
15
16
17
# File 'lib/decidim/decidim_awesome/context_analyzers/participatory_space_analyzer.rb', line 13

def self.context_for(participatory_space)
  analyzer = new participatory_space
  analyzer.extract_context!
  analyzer.context
end

Instance Method Details

#extract_context!Object



21
22
23
24
25
26
27
# File 'lib/decidim/decidim_awesome/context_analyzers/participatory_space_analyzer.rb', line 21

def extract_context!
  return unless @participatory_space.respond_to? :manifest
  return unless @participatory_space.manifest.is_a? Decidim::ParticipatorySpaceManifest

  @context[:participatory_space_manifest] = @participatory_space.manifest.name.to_s
  @context[:participatory_space_slug] = @participatory_space&.slug
end