Module: Technoweenie::AttachmentFu::Backends::DbFileBackend

Defined in:
lib/technoweenie/attachment_fu/backends/db_file_backend.rb

Overview

Methods for DB backed attachments

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

:nodoc:



6
7
8
9
# File 'lib/technoweenie/attachment_fu/backends/db_file_backend.rb', line 6

def self.included(base) #:nodoc:
  Object.const_set(:DbFile, Class.new(ActiveRecord::Base)) unless Object.const_defined?(:DbFile)
  base.belongs_to  :db_file, :class_name => '::DbFile', :foreign_key => 'db_file_id'
end

Instance Method Details

#create_temp_fileObject

Creates a temp file with the current db data.



12
13
14
# File 'lib/technoweenie/attachment_fu/backends/db_file_backend.rb', line 12

def create_temp_file
  write_to_temp_file current_data
end

#current_dataObject

Gets the current data from the database



17
18
19
# File 'lib/technoweenie/attachment_fu/backends/db_file_backend.rb', line 17

def current_data
  db_file.data
end