Class: Simplec::EmbeddedImage

Inherits:
ApplicationRecord show all
Defined in:
app/models/simplec/embedded_image.rb

Overview

An embedded image in an editor field.

For the most part you don't need to utilize this record. These records are created by summernote and the administration of creating them is handled by the Simplec Engine.

There is an #embedded_images association on a `Simplec::Page` record.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#assetDragonfly::Model::Attachment?

Returns The embedded asset.

Returns:

  • (Dragonfly::Model::Attachment, nil)

    The embedded asset


23
# File 'app/models/simplec/embedded_image.rb', line 23

dragonfly_accessor :asset

#asset_nameString?

Returns The name of the Dragonfly #asset.

Returns:

  • (String, nil)

    The name of the Dragonfly #asset


# File 'app/models/simplec/embedded_image.rb', line 34

#asset_uidString?

Returns The unique id of the Dragonfly #asset.

Returns:

  • (String, nil)

    The unique id of the Dragonfly #asset


# File 'app/models/simplec/embedded_image.rb', line 31

#embeddableObject?

The object that owns the embedded image

Returns:

  • (Object, nil)

    An ActiveRecord object


17
18
19
# File 'app/models/simplec/embedded_image.rb', line 17

belongs_to :embeddable,
polymorphic: true,
optional: true

#embeddable_idString, ...

Returns The uuid (or id) of the #embeddable association.

Returns:

  • (String, Integer, nil)

    The uuid (or id) of the #embeddable association


# File 'app/models/simplec/embedded_image.rb', line 28

#embeddable_typeString?

Returns The type of the #embeddable association.

Returns:

  • (String, nil)

    The type of the #embeddable association


# File 'app/models/simplec/embedded_image.rb', line 25

Instance Method Details

#urlString Also known as: asset_url

Dragonfly url for the asset.

Returns:

  • (String)

    the url for the dragonfly asset


40
41
42
43
44
# File 'app/models/simplec/embedded_image.rb', line 40

def url
  return unless self.asset
  return self.asset.url unless persisted?
  self.asset.url(ei: Base64.urlsafe_encode64(self.id.to_s))
end