Module: PrometheeData
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActionView::Helpers::SanitizeHelper
- Defined in:
- app/models/concerns/promethee_data.rb
Instance Method Summary collapse
-
#data=(value) ⇒ Object
Setter to serialize data as JSON.
- #promethee_data_page_description ⇒ Object
- #promethee_data_page_description=(value) ⇒ Object
- #promethee_data_page_thumbnail ⇒ Object
-
#promethee_data_page_title ⇒ Object
Getters and setters to get PAGE Title, Description & Thumbnail.
- #promethee_data_page_title=(value) ⇒ Object
- #promethee_data_searchable ⇒ Object
- #promethee_data_translation_description ⇒ Object
-
#promethee_data_translation_title ⇒ Object
Getters to get TRANSLATION Title & Description.
Instance Method Details
#data=(value) ⇒ Object
Setter to serialize data as JSON
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/models/concerns/promethee_data.rb', line 5 def data=(value) value = JSON.parse value if value.is_a? String if value.has_key? 'components' # For translations, contents are in components, not children value['components'].map { |component| promethee_sanitize(component) } else # For masters, contents are in children value = promethee_sanitize(value) end super(value) end |
#promethee_data_page_description ⇒ Object
29 30 31 32 33 |
# File 'app/models/concerns/promethee_data.rb', line 29 def promethee_data_page_description data['attributes']['description']['value'] rescue '' end |
#promethee_data_page_description=(value) ⇒ Object
35 36 37 |
# File 'app/models/concerns/promethee_data.rb', line 35 def promethee_data_page_description=(value) self.data['attributes']['description']['value'] = value end |
#promethee_data_page_thumbnail ⇒ Object
39 40 41 42 43 44 |
# File 'app/models/concerns/promethee_data.rb', line 39 def promethee_data_page_thumbnail blob_find_method = ActiveStorage::Blob.respond_to?(:find_signed!) ? :find_signed! : :find_signed ActiveStorage::Blob.public_send blob_find_method, data['attributes']['thumbnail']['value']['id'] rescue nil end |
#promethee_data_page_title ⇒ Object
Getters and setters to get PAGE Title, Description & Thumbnail
19 20 21 22 23 |
# File 'app/models/concerns/promethee_data.rb', line 19 def promethee_data_page_title data['attributes']['title']['value'] rescue '' end |
#promethee_data_page_title=(value) ⇒ Object
25 26 27 |
# File 'app/models/concerns/promethee_data.rb', line 25 def promethee_data_page_title=(value) self.data['attributes']['title']['value'] = value end |
#promethee_data_searchable ⇒ Object
59 60 61 |
# File 'app/models/concerns/promethee_data.rb', line 59 def promethee_data_searchable promethee_extract_searchable data end |
#promethee_data_translation_description ⇒ Object
53 54 55 56 57 |
# File 'app/models/concerns/promethee_data.rb', line 53 def promethee_data_translation_description data['components'].first['attributes']['description']['value'] rescue '' end |
#promethee_data_translation_title ⇒ Object
Getters to get TRANSLATION Title & Description
47 48 49 50 51 |
# File 'app/models/concerns/promethee_data.rb', line 47 def promethee_data_translation_title data['components'].first['attributes']['title']['value'] rescue '' end |