public
Description: Treat an ActiveRecord model as a file attachment, storing its patch, size, content type, etc.
Homepage: http://weblog.techno-weenie.net
Clone URL: git://github.com/technoweenie/attachment_fu.git
Click here to lend your support to: attachment_fu and make a donation at www.pledgie.com !
restructure init.rb to allow reloading in rails plugins
rick (author)
Wed Apr 23 18:25:58 -0700 2008
commit  324b3ab0615d503646b8292639d5022ffbf455a7
tree    202a3343804054dc270d6e4d0563c4c420bc657c
parent  f5a293a6826b9056503c32dac1840ffbae167faf
...
1
2
 
 
 
 
 
 
 
 
 
 
 
3
...
 
1
2
3
4
5
6
7
8
9
10
11
12
13
0
@@ -1 +1,11 @@
0
-AttachmentFu.setup ActiveRecord::Base
0
\ No newline at end of file
0
+Dependencies.load_once_paths << File.expand_path(File.join(lib_path, '..', 'vendor'))
0
+
0
+config.after_initialize do
0
+ AttachmentFu.setup ActiveRecord::Base
0
+ AttachmentFu.reset
0
+end
0
+
0
+config.to_prepare do
0
+ AttachmentFu.setup ActiveRecord::Base
0
+ AttachmentFu.reset
0
+end
0
\ No newline at end of file
...
74
75
76
 
 
 
 
 
 
 
 
 
77
78
79
...
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
0
@@ -74,6 +74,15 @@ module AttachmentFu
0
     klass.extend SetupMethods
0
   end
0
 
0
+ # Sets default tasks
0
+ def self.reset
0
+ Tasks
0
+ [:resize, :thumbnails].each do |task|
0
+ create_task task, "attachment_fu/tasks/#{task}"
0
+ end
0
+ create_task :get_image_size, "attachment_fu/tasks/resize"
0
+ end
0
+
0
   # This mixin is included in attachment classes by AttachmentFu::SetupMethods.is_attachment.
0
   module InstanceMethods
0
     def self.included(base)
...
63
64
65
66
 
67
68
69
...
158
159
160
161
162
163
164
165
166
167
168
 
169
...
63
64
65
 
66
67
68
69
...
158
159
160
 
 
 
 
 
 
 
161
162
163
0
@@ -63,7 +63,7 @@ module AttachmentFu
0
     def self.[](key)
0
       case value = all[key]
0
         when String
0
- require value
0
+ send respond_to?(:require_dependency) ? :require_dependency : :require, value
0
           if all[key].is_a?(String) then raise(ArgumentError, "loading #{key.inspect} failed.") end
0
           all[key]
0
         else value
0
@@ -158,10 +158,4 @@ module AttachmentFu
0
       end || raise(ArgumentError, "Invalid Key: #{key_or_index.inspect}")
0
     end
0
   end
0
-end
0
-
0
-# default tasks
0
-[:resize, :thumbnails].each do |task|
0
- AttachmentFu.create_task task, "attachment_fu/tasks/#{task}"
0
-end
0
-AttachmentFu.create_task :get_image_size, "attachment_fu/tasks/resize"
0
\ No newline at end of file
0
+end
0
\ No newline at end of file

Comments

    No one has commented yet.