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.
@@ -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 has_attachment_methods(options={})
14
+ def require_column(column, message)
15
15
  begin
16
- raise "Milton requires a filename column on #{class_name} table" unless column_names.include?("filename")
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
@@ -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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: citrusbyte-milton
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Alavi