Class: Decidim::ContextualHelpSection
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::ContextualHelpSection
- Includes:
- Traceable, TranslatableResource
- Defined in:
- app/models/decidim/contextual_help_section.rb
Class Method Summary collapse
-
.find_content(organization, id) ⇒ Object
Public: Finds content given an id.
- .log_presenter_class_for(_log) ⇒ Object
-
.set_content(organization, id, content) ⇒ Object
Public: Stores the content.
Class Method Details
.find_content(organization, id) ⇒ Object
Public: Finds content given an id
organization - The Organization to scope the content to id - A String with the id
Returns a Hash with the localized content
23 24 25 |
# File 'app/models/decidim/contextual_help_section.rb', line 23 def self.find_content(organization, id) find_by(organization:, section_id: id).try(:content) || {} end |
.log_presenter_class_for(_log) ⇒ Object
13 14 15 |
# File 'app/models/decidim/contextual_help_section.rb', line 13 def self.log_presenter_class_for(_log) Decidim::AdminLog::ContextualHelpSectionPresenter end |
.set_content(organization, id, content) ⇒ Object
Public: Stores the content.
organization - The Organization to scope the content to id - A String with the id content - A Hash with the content to store
Returns a Hash with the localized content
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/models/decidim/contextual_help_section.rb', line 34 def self.set_content(organization, id, content) item = find_or_initialize_by( organization:, section_id: id ) if content.present? && content.values.any?(&:present?) item.update!(content:) else item.destroy! end content end |