Class: ActionText::Attachables::ContentAttachment
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
|
|
|
Instance Chain:
|
|
| Inherits: | Object |
| Defined in: | actiontext/lib/action_text/attachables/content_attachment.rb |
Class Method Summary
::ActiveModel::Callbacks - self
::ActiveModel::Naming - self
| param_key | Returns string to use for params names. |
| plural | Returns the plural class name of a record or class. |
| route_key | Returns string to use while generating route names. |
| singular | Returns the singular class name of a record or class. |
| singular_route_key | Returns string to use while generating route names. |
| uncountable? | Identifies whether the class name of a record or class is uncountable. |
| extended, model_name_from_record_or_class | |
Instance Attribute Summary
- #content rw
- #content_type rw
::ActiveModel::API - Included
| #_validators, #_validators?, | |
| #persisted? | Indicates if the model is persisted. |
::ActiveModel::Validations - Included
| #validation_context | Returns the context when running validations. |
| #validation_context= | |
::ActiveModel::AttributeAssignment - Included
Instance Method Summary
- #attachable_plain_text_representation(caption)
- #to_html
- #to_partial_path
- #to_s
- #content_instance private
::ActiveModel::Access - Included
::ActiveModel::API - Included
| #initialize | Initializes a new model with the given |
::ActiveModel::Conversion - Included
| #to_key | Returns an |
| #to_model | If your object is already designed to implement all of the Active Model you can use the default |
| #to_param | Returns a |
| #to_partial_path | Returns a |
::ActiveModel::Validations::HelperMethods - Included
| #validates_absence_of | Validates that the specified attributes are blank (as defined by Object#present?). |
| #validates_acceptance_of | Encapsulates the pattern of wanting to validate the acceptance of a terms of service check box (or similar agreement). |
| #validates_comparison_of | Validates the value of a specified attribute fulfills all defined comparisons with another value, proc, or attribute. |
| #validates_confirmation_of | Encapsulates the pattern of wanting to validate a password or email address field with a confirmation. |
| #validates_exclusion_of | Validates that the value of the specified attribute is not in a particular enumerable object. |
| #validates_format_of | Validates whether the value of the specified attribute is of the correct form, going by the regular expression provided. |
| #validates_inclusion_of | Validates whether the value of the specified attribute is available in a particular enumerable object. |
| #validates_length_of | Validates that the specified attributes match the length restrictions supplied. |
| #validates_numericality_of | Validates whether the value of the specified attribute is numeric by trying to convert it to a float with |
| #validates_presence_of | Validates that the specified attributes are not blank (as defined by Object#blank?). |
| #validates_size_of | |
| #_merge_attributes | |
::ActiveModel::Validations - Included
| #errors | Returns the |
| #freeze, | |
| #invalid? | Performs the opposite of |
| #read_attribute_for_validation | Hook method defining how an attribute value should be retrieved. |
| #valid? | Runs all the specified validations and returns |
| #validate | Alias for ActiveModel::Validations#valid?. |
| #validate! | Runs all the validations within the specified context. |
| #validates_with | Passes the record off to the class or classes specified and allows them to add errors based on more complex conditions. |
| #context_for_validation, #init_internals, #raise_validation_error, #run_validations!, | |
| #initialize_dup | Clean the |
::ActiveModel::AttributeAssignment - Included
| #assign_attributes | Allows you to set all the attributes by passing in a hash of attributes with keys matching the attribute names. |
| #attribute_writer_missing | Like |
| #_assign_attribute, #_assign_attributes | |
::ActiveModel::ForbiddenAttributesProtection - Included
Class Method Details
.from_node(node)
[ GitHub ]# File 'actiontext/lib/action_text/attachables/content_attachment.rb', line 10
def self.from_node(node) = new(content_type: node["content-type"], content: node["content"]) if .valid? end
Instance Attribute Details
#content (rw)
[ GitHub ]# File 'actiontext/lib/action_text/attachables/content_attachment.rb', line 15
attr_accessor :content_type, :content
#content_type (rw)
[ GitHub ]# File 'actiontext/lib/action_text/attachables/content_attachment.rb', line 15
attr_accessor :content_type, :content
Instance Method Details
#attachable_plain_text_representation(caption)
[ GitHub ]# File 'actiontext/lib/action_text/attachables/content_attachment.rb', line 20
def attachable_plain_text_representation(caption) content_instance.fragment.source end
#content_instance (private)
[ GitHub ]# File 'actiontext/lib/action_text/attachables/content_attachment.rb', line 37
def content_instance @content_instance ||= ActionText::Content.new(content) end
#to_html
[ GitHub ]# File 'actiontext/lib/action_text/attachables/content_attachment.rb', line 24
def to_html @to_html ||= content_instance.render(content_instance) end
#to_partial_path
[ GitHub ]# File 'actiontext/lib/action_text/attachables/content_attachment.rb', line 32
def to_partial_path "action_text/attachables/content_attachment" end
#to_s
[ GitHub ]# File 'actiontext/lib/action_text/attachables/content_attachment.rb', line 28
def to_s to_html end