grip 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,7 +13,7 @@ The grip gem is hosted on gemcutter.org:
13
13
 
14
14
  class Doc
15
15
  include MongoMapper::Document
16
- include Grip
16
+ include MongoMapper::Grip::HasAttachment
17
17
 
18
18
  has_grid_attachment :image, :versions => {:thumb => {:width=>50,:height=>50}}
19
19
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.6.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{grip}
8
- s.version = "0.6.0"
8
+ s.version = "0.6.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["twoism", "jnunemaker"]
@@ -16,6 +16,7 @@ module MongoMapper
16
16
  key :variants, Hash
17
17
 
18
18
  after_save :build_variants
19
+ before_destroy :destroy_file
19
20
 
20
21
  def file=new_file
21
22
  raise InvalidFile unless (new_file.is_a?(File) || new_file.is_a?(Tempfile))
@@ -35,12 +36,6 @@ module MongoMapper
35
36
  "#{owner_type.pluralize}/#{owner_id}/#{name}".downcase
36
37
  end
37
38
 
38
- def self.create_method sym, &block
39
- define_method sym do |*block.args|
40
- yield
41
- end
42
- end
43
-
44
39
  private
45
40
  def build_variants
46
41
  self.variants.each do |variant, dimensions|
@@ -69,6 +64,10 @@ module MongoMapper
69
64
 
70
65
  end
71
66
  end
67
+
68
+ def destroy_file
69
+ GridFS::GridStore.unlink(self.class.database, grid_key)
70
+ end
72
71
 
73
72
  def write_to_grid new_file
74
73
  GridFS::GridStore.open(self.class.database, grid_key, 'w', :content_type => content_type) do |f|
@@ -30,8 +30,7 @@ module MongoMapper
30
30
  def self.included(base)
31
31
  base.extend ClassMethods
32
32
  base.class_eval do
33
- after_save :save_attachments
34
- before_destroy :destroy_attached_files
33
+ after_save :save_attachments
35
34
 
36
35
  many :attachments, :as => :owner, :class_name => "MongoMapper::Grip::Attachment", :dependent => :destroy
37
36
  end
@@ -26,10 +26,6 @@ class HasAttachmentTest < Test::Unit::TestCase
26
26
  assert_equal(1, Doc.after_save.collect(&:method).count)
27
27
  end
28
28
 
29
- should "have :before_destroy callback" do
30
- assert_equal(1, Doc.before_destroy.collect(&:method).count)
31
- end
32
-
33
29
  context "when assigned a file" do
34
30
  setup do
35
31
  @document.image = @image
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - twoism