Module: DirectWave::ActiveRecord

Includes:
Mounter
Defined in:
lib/directwave/orm/activerecord.rb

Instance Method Summary collapse

Methods included from Mounter

#uploaders

Instance Method Details

#mount_directwave(column, uploader = nil) ⇒ Object

See DirectWave::Mounter#mount_uploader for documentation

Added instance methods

Supposing a class has used mount_uploader to mount an uploader on a column named image, in that case the following methods will be added to the class:

#column_from_key

Returns the key of assigned file

#column_from_key=

Assign file from S3 key



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/directwave/orm/activerecord.rb', line 20

def mount_directwave(column, uploader=nil)
  super

  instance_eval "", __FILE__, __LINE__+1
  
  class_eval "attr_accessible :\#{column}_from_key\n\ndef \#{column}_from_key\nsend(:\#{column}).store_key\nend\n\ndef \#{column}_from_key=(string)\nsend(:\#{column}).store_key = string\nend\n\nbefore_save do\nsend(:\#{column}).save\nend\n\nafter_destroy do\nsend(:\#{column}).destroy\nend\n", __FILE__, __LINE__+1
end