Class: Spina::Attachment

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_destroyObject

Returns the value of attribute _destroy.



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

def _destroy
  @_destroy
end

Instance Method Details

#contentObject



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

def content
  file if file.attached?
end

#nameObject



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

def name
  file.filename.to_s
end

#old_updateObject



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

alias_method :old_update, :update

#update(attributes) ⇒ Object



22
23
24
25
26
27
28
# File 'app/models/spina/attachment.rb', line 22

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