Class: Spina::Parts::Image

Inherits:
Base
  • Object
show all
Defined in:
app/models/spina/parts/image.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#hint, #item_name, #title

Instance Method Summary collapse

Methods inherited from Base

#label

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



9
10
11
# File 'app/models/spina/parts/image.rb', line 9

def options
  @options
end

Instance Method Details

#contentObject



15
16
17
# File 'app/models/spina/parts/image.rb', line 15

def content
  self
end

#present?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/models/spina/parts/image.rb', line 27

def present?
  signed_blob_id.present?
end

#signed_id(expires_at: nil, expires_in: nil) ⇒ Object

Rails 7.1 started using ‘expires_at’, so we include both expires_in and expires_at for backwards compatibility



34
35
36
# File 'app/models/spina/parts/image.rb', line 34

def signed_id(expires_at: nil, expires_in: nil)
  signed_blob_id
end

#spina_imageObject



23
24
25
# File 'app/models/spina/parts/image.rb', line 23

def spina_image
  Spina::Image.find_by(id: image_id)
end

#svg?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'app/models/spina/parts/image.rb', line 19

def svg?
  filename.end_with?(".svg")
end

#to_sObject



11
12
13
# File 'app/models/spina/parts/image.rb', line 11

def to_s
  alt.presence || filename.presence || Spina::Image.model_name.human
end

#variant(options) ⇒ Object



38
39
40
# File 'app/models/spina/parts/image.rb', line 38

def variant(options)
  Spina::Parts::ImageVariant.new(self, options)
end