Class: Spina::Attachment

Inherits:
ApplicationRecord show all
Includes:
Attachable
Defined in:
app/models/spina/attachment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Attachable

#name

Methods inherited from ApplicationRecord

#to_partial_path

Instance Attribute Details

#_destroyObject

Returns the value of attribute _destroy.



5
6
7
# File 'app/models/spina/attachment.rb', line 5

def _destroy
  @_destroy
end

Instance Method Details

#contentObject



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

def content
  file if file.attached?
end

#old_updateObject



17
# File 'app/models/spina/attachment.rb', line 17

alias_method :old_update, :update

#present?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'app/models/spina/attachment.rb', line 13

def present?
  signed_blob_id.present?
end

#update(attributes) ⇒ Object



18
19
20
21
22
23
24
# File 'app/models/spina/attachment.rb', line 18

def update(attributes)
  if attributes["_destroy"] == "1" && attributes["file"].blank?
    page_part.destroy
  else
    old_update(attributes)
  end
end