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

#fileObject



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

def file
  @file ||= attachment ? attachment.file : nil
end

#file=(file) ⇒ Object



64
65
66
67
68
69
70
71
72
# 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
  @file = file
  self.build_attachment(:file => file)
end

#filepathObject



78
79
80
# File 'lib/versions/attachment.rb', line 78

def filepath
  attachment ? attachment.filepath : nil
end