Module: Versions::Attachment::Owner

Defined in:
lib/versions/attachment.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



56
57
58
59
60
61
62
# File 'lib/versions/attachment.rb', line 56

def self.included(base)
  base.class_eval do
    before_create  :save_attachment
    before_update  :attachment_before_update
    before_destroy :attachment_before_destroy
  end
end

Instance Method Details

#file=(file) ⇒ Object



64
65
66
67
68
69
70
71
# File 'lib/versions/attachment.rb', line 64

def file=(file)
  if attachment
    @attachment_to_unlink = self.attachment
    self.attachment = nil
  end
  @attachment_need_save = true
  self.build_attachment(:file => file)
end

#filepathObject



73
74
75
# File 'lib/versions/attachment.rb', line 73

def filepath
  attachment ? attachment.filepath : nil
end