Methods
- A
- F
- P
- T
Constants
LOCATOR_NAME | = | "attachable" |
Class Public methods
from_attachable_sgid(sgid, options = {}) Link
# File actiontext/lib/action_text/attachable.rb, line 22 def from_attachable_sgid(sgid, options = {}) method = sgid.is_a?(Array) ? :locate_many_signed : :locate_signed record = GlobalID::Locator.public_send(method, sgid, options.merge(for: LOCATOR_NAME)) record || raise(ActiveRecord::RecordNotFound) end
from_node(node) Link
# File actiontext/lib/action_text/attachable.rb, line 10 def from_node(node) if attachable = attachable_from_sgid(node["sgid"]) attachable elsif attachable = ActionText::Attachables::ContentAttachment.from_node(node) attachable elsif attachable = ActionText::Attachables::RemoteImage.from_node(node) attachable else ActionText::Attachables::MissingAttachable end end
Instance Public methods
as_json(*) Link
attachable_content_type() Link
attachable_filename() Link
attachable_filesize() Link
attachable_metadata() Link
attachable_sgid() Link
from_attachable_sgid(sgid) Link
previewable_attachable?() Link
to_attachable_partial_path() Link
to_rich_text_attributes(attributes = {}) Link
# File actiontext/lib/action_text/attachable.rb, line 78 def to_rich_text_attributes(attributes = {}) attributes.dup.tap do |attrs| attrs[:sgid] = attachable_sgid attrs[:content_type] = attachable_content_type attrs[:previewable] = true if previewable_attachable? attrs[:filename] = attachable_filename attrs[:filesize] = attachable_filesize attrs[:width] = attachable_metadata[:width] attrs[:height] = attachable_metadata[:height] end.compact end