citrusbyte-milton 0.1.9 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/milton/attachment.rb +7 -3
- data/lib/milton/is_resizeable.rb +2 -2
- metadata +1 -1
data/lib/milton/attachment.rb
CHANGED
@@ -3,7 +3,7 @@ require 'fileutils'
|
|
3
3
|
|
4
4
|
module Citrusbyte
|
5
5
|
module Milton
|
6
|
-
module Attachment
|
6
|
+
module Attachment
|
7
7
|
def self.included(base)
|
8
8
|
base.class_inheritable_accessor :milton_options
|
9
9
|
base.milton_options = {}
|
@@ -11,12 +11,16 @@ module Citrusbyte
|
|
11
11
|
end
|
12
12
|
|
13
13
|
module AttachmentMethods
|
14
|
-
def
|
14
|
+
def require_column(column, message)
|
15
15
|
begin
|
16
|
-
raise
|
16
|
+
raise message unless column_names.include?(column)
|
17
17
|
rescue ActiveRecord::StatementInvalid => i
|
18
18
|
# table doesn't exist yet, i.e. hasn't been migrated in...
|
19
19
|
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def has_attachment_methods(options={})
|
23
|
+
require_column 'filename', "Milton requires a filename column on #{class_name} table"
|
20
24
|
|
21
25
|
# character used to seperate a filename from its derivative options, this
|
22
26
|
# character will be stripped from all incoming filenames and replaced by
|
data/lib/milton/is_resizeable.rb
CHANGED
@@ -7,9 +7,9 @@ module Citrusbyte
|
|
7
7
|
|
8
8
|
module IsMethods
|
9
9
|
def is_resizeable(options={})
|
10
|
-
raise "is_resizeable requires a content_type column on #{class_name} table" unless column_names.include?("content_type")
|
11
|
-
|
12
10
|
ensure_attachment_methods options
|
11
|
+
|
12
|
+
require_column 'content_type', "Milton's is_resizeable requires a content_type column on #{class_name} table"
|
13
13
|
|
14
14
|
self.milton_options.merge!(options)
|
15
15
|
|