Class: ActionText::Attachment
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
|
|
Inherits: | Object |
Defined in: | actiontext/lib/action_text/attachment.rb |
Constant Summary
-
ATTRIBUTES =
# File 'actiontext/lib/action_text/attachment.rb', line 11%w( sgid content-type url href filename filesize width height previewable presentation caption )
-
SELECTOR =
# File 'actiontext/lib/action_text/attachment.rb', line 10TAG_NAME
-
TAG_NAME =
# File 'actiontext/lib/action_text/attachment.rb', line 9"action-text-attachment"
Class Method Summary
Instance Attribute Summary
- #attachable readonly
- #node readonly
Instance Method Summary
Attachments::TrixConversion
- Included
Attachments::Caching
- Included
Constructor Details
.new(node, attachable) ⇒ Attachment
# File 'actiontext/lib/action_text/attachment.rb', line 55
def initialize(node, attachable) @node = node @attachable = attachable end
Class Method Details
.fragment_by_canonicalizing_attachments(content)
[ GitHub ]# File 'actiontext/lib/action_text/attachment.rb', line 14
def (content) ( (content)) end
.from_attachable(attachable, attributes = {})
[ GitHub ]# File 'actiontext/lib/action_text/attachment.rb', line 26
def from_attachable(attachable, attributes = {}) if node = node_from_attributes(attachable.to_rich_text_attributes(attributes)) new(node, attachable) end end
.from_attachables(attachables)
[ GitHub ]# File 'actiontext/lib/action_text/attachment.rb', line 22
def from_attachables(attachables) Array(attachables).map { |attachable| from_attachable(attachable) }.compact end
.from_attributes(attributes, attachable = nil)
[ GitHub ]# File 'actiontext/lib/action_text/attachment.rb', line 32
def from_attributes(attributes, attachable = nil) if node = node_from_attributes(attributes) from_node(node, attachable) end end
.from_node(node, attachable = nil)
[ GitHub ]# File 'actiontext/lib/action_text/attachment.rb', line 18
def from_node(node, attachable = nil) new(node, attachable || ActionText::Attachable.from_node(node)) end
Instance Attribute Details
#attachable (readonly)
[ GitHub ]# File 'actiontext/lib/action_text/attachment.rb', line 50
attr_reader :node, :attachable
#node (readonly)
[ GitHub ]# File 'actiontext/lib/action_text/attachment.rb', line 50
attr_reader :node, :attachable
Instance Method Details
#full_attributes
[ GitHub ]# File 'actiontext/lib/action_text/attachment.rb', line 64
def full_attributes node_attributes.merge(attachable_attributes).merge(sgid_attributes) end
#inspect
[ GitHub ]# File 'actiontext/lib/action_text/attachment.rb', line 88
def inspect "#<#{self.class.name} attachable=#{attachable.inspect}>" end
#to_html
[ GitHub ]# File 'actiontext/lib/action_text/attachment.rb', line 80
def to_html HtmlConversion.node_to_html(node) end
#to_param
[ GitHub ]# File 'actiontext/lib/action_text/attachment.rb', line 52
delegate :to_param, to: :attachable
#to_plain_text
[ GitHub ]# File 'actiontext/lib/action_text/attachment.rb', line 72
def to_plain_text if respond_to?(:attachable_plain_text_representation) attachable_plain_text_representation( ) else .to_s end end
#to_s
[ GitHub ]# File 'actiontext/lib/action_text/attachment.rb', line 84
def to_s to_html end
#with_full_attributes
[ GitHub ]# File 'actiontext/lib/action_text/attachment.rb', line 68
def with_full_attributes self.class.from_attributes(full_attributes, attachable) end