Class: Decidim::Feature
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::Feature
- 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
-
#manifest ⇒ Object
Public: Finds the manifest this feature is associated to.
-
#manifest=(manifest) ⇒ Object
Public: Assigns a manifest to this feature.
-
#mounted_admin_engine ⇒ Object
Public: The name of the admin engine the feature is mounted to.
-
#mounted_engine ⇒ Object
Public: The name of the engine the feature is mounted to.
-
#mounted_params ⇒ Object
Public: The hash of contextual params when the feature is mounted.
-
#primary_stat ⇒ Object
Public: Returns the value of the registered primary stat.
Methods included from Publicable
#publish!, #published?, #unpublish!
Methods included from HasSettings
#current_settings, #default_step_settings, #default_step_settings=, #settings, #settings=, #step_settings, #step_settings=
Instance Method Details
#manifest ⇒ Object
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 |
#mounted_admin_engine ⇒ Object
Public: The name of the admin engine the feature is mounted to.
40 41 42 |
# File 'decidim-core/app/models/decidim/feature.rb', line 40 def mounted_admin_engine "decidim_admin_#{participatory_space_name}_#{manifest_name}" end |
#mounted_engine ⇒ Object
Public: The name of the engine the feature is mounted to.
35 36 37 |
# File 'decidim-core/app/models/decidim/feature.rb', line 35 def mounted_engine "decidim_#{participatory_space_name}_#{manifest_name}" end |
#mounted_params ⇒ Object
Public: The hash of contextual params when the feature is mounted.
45 46 47 48 49 50 51 |
# File 'decidim-core/app/models/decidim/feature.rb', line 45 def mounted_params { host: organization.host, feature_id: id, participatory_space.foreign_key.to_sym => participatory_space.id } end |
#primary_stat ⇒ Object
Public: Returns the value of the registered primary stat.
54 55 56 |
# File 'decidim-core/app/models/decidim/feature.rb', line 54 def primary_stat @primary_stat ||= manifest.stats.filter(primary: true).with_context([self]).map { |name, value| [name, value] }.first&.last end |