Class: ActionText::Attachables::ContentAttachment

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
actiontext/lib/action_text/attachables/content_attachment.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ActiveSupport::Concern

#append_features, #class_methods, extended, #included, #prepend_features, #prepended

Methods included from ActiveModel::Access

#slice, #values_at

Methods included from ActiveModel::API

#initialize, #persisted?

Methods included from ActiveModel::Conversion

#to_key, #to_model, #to_param

Methods included from ActiveModel::Validations

#errors, #initialize_dup, #invalid?, #valid?, #validate!, #validates_with

Methods included from ActiveModel::AttributeAssignment

#assign_attributes

Instance Attribute Details

#contentObject

Returns the value of attribute content



13
14
15
# File 'actiontext/lib/action_text/attachables/content_attachment.rb', line 13

def content
  @content
end

#content_typeObject

Returns the value of attribute content_type



13
14
15
# File 'actiontext/lib/action_text/attachables/content_attachment.rb', line 13

def content_type
  @content_type
end

Class Method Details

.from_node(node) ⇒ Object



8
9
10
11
# File 'actiontext/lib/action_text/attachables/content_attachment.rb', line 8

def self.from_node(node)
  attachment = new(content_type: node["content-type"], content: node["content"])
  attachment if attachment.valid?
end

Instance Method Details

#attachable_plain_text_representation(caption) ⇒ Object



18
19
20
# File 'actiontext/lib/action_text/attachables/content_attachment.rb', line 18

def attachable_plain_text_representation(caption)
  content_instance.fragment.source
end

#to_htmlObject



22
23
24
# File 'actiontext/lib/action_text/attachables/content_attachment.rb', line 22

def to_html
  @to_html ||= content_instance.render(content_instance)
end

#to_partial_pathObject



30
31
32
# File 'actiontext/lib/action_text/attachables/content_attachment.rb', line 30

def to_partial_path
  "action_text/attachables/content_attachment"
end

#to_sObject



26
27
28
# File 'actiontext/lib/action_text/attachables/content_attachment.rb', line 26

def to_s
  to_html
end