Class: Fields::RichTextArea

Inherits:
Field
  • Object
show all
Includes:
ActionView::Helpers::TagHelper
Defined in:
app/models/iron/fields/rich_text_area.rb

Instance Method Summary collapse

Instance Method Details

#content_value=(value) ⇒ Object



7
8
9
# File 'app/models/iron/fields/rich_text_area.rb', line 7

def content_value=(value)
  self.rich_text = value
end

#export_attachmentsObject



31
32
33
34
35
36
37
# File 'app/models/iron/fields/rich_text_area.rb', line 31

def export_attachments
  return [] unless rich_text&.body.present?

  rich_text.body.attachables.filter_map do |attachable|
    attachable.blob if attachable.respond_to?(:blob)
  end
end

#export_valueObject



21
22
23
24
25
26
27
28
29
# File 'app/models/iron/fields/rich_text_area.rb', line 21

def export_value
  return { type: "rich_text_area", value: nil } unless rich_text&.body.present?

  html = rich_text.body.render_attachments do |attachment|
    export_attachment_tag(attachment)
  end.to_html

  { type: "rich_text_area", value: html }
end

#filled?Boolean

Returns:



11
# File 'app/models/iron/fields/rich_text_area.rb', line 11

def filled? = rich_text&.body.present?

#searchable_textObject



13
14
15
# File 'app/models/iron/fields/rich_text_area.rb', line 13

def searchable_text
  rich_text&.to_plain_text
end

#valueObject



17
18
19
# File 'app/models/iron/fields/rich_text_area.rb', line 17

def value
  rich_text&.to_s
end