Class: Decidim::Feature

Inherits:
ApplicationRecord show all
Includes:
HasSettings, Publicable
Defined in:
decidim-core/app/models/decidim/feature.rb

Overview

A Feature represents a self-contained group of functionalities usually defined via a FeatureManifest. It’s meant to be able to provide a single feature that spans over several steps.

Instance Method Summary collapse

Methods included from Publicable

#publish!, #published?, #unpublish!

Methods included from HasSettings

#active_step_settings, #default_step_settings, #default_step_settings=, #settings, #settings=, #step_settings, #step_settings=

Instance Method Details

#manifestObject

Public: Finds the manifest this feature is associated to.

Returns a FeatureManifest.



21
22
23
# File 'decidim-core/app/models/decidim/feature.rb', line 21

def manifest
  Decidim.find_feature_manifest(manifest_name)
end

#manifest=(manifest) ⇒ Object

Public: Assigns a manifest to this feature.

manifest - The FeatureManifest for this Feature.

Returns nothing.



30
31
32
# File 'decidim-core/app/models/decidim/feature.rb', line 30

def manifest=(manifest)
  self.manifest_name = manifest.name
end

#primary_statObject

Public: Returns the value of the registered primary stat.



35
36
37
# File 'decidim-core/app/models/decidim/feature.rb', line 35

def primary_stat
  @primary_stat ||= manifest.stats.filter(primary: true).with_context([self]).map { |name, value| [name, value] }.first&.last
end