module Notebook::ActiveRecordAttachment::ClassMethods

Public Instance Methods

notebook_attachment(name) click to toggle source

Attachment method which hooks into ActiveRecord models

# File lib/notebook/rails/active_record.rb, line 9
def notebook_attachment(name)
  define_method "#{name}" do
    @notebook_attachment
  end

  define_method "#{name}=" do |value|
    @notebook_attachment = Notebook::Attachment.new(value)
    @notebook_attachment.upload
    @notebook_attachment
  end

  after_destroy do
    @notebook_attachment.delete
  end
end