grip 0.6.5 → 0.6.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.5
1
+ 0.6.6
data/grip.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{grip}
8
- s.version = "0.6.5"
8
+ s.version = "0.6.6"
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"]
12
- s.date = %q{2010-01-13}
12
+ s.date = %q{2010-01-15}
13
13
  s.description = %q{GridFS attachments for MongoMapper}
14
14
  s.email = %q{signalstatic@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -4,7 +4,6 @@ module Grip
4
4
  def self.included(base)
5
5
  base.extend ClassMethods
6
6
  base.instance_eval do
7
- after_save :save_attachments
8
7
  many :attachments,
9
8
  :as => :owner,
10
9
  :class_name => "Grip::Attachment",
@@ -15,12 +14,16 @@ module Grip
15
14
  module ClassMethods
16
15
 
17
16
  def has_grid_attachment name, opts={}
17
+ set_callbacks_once
18
+
18
19
  write_inheritable_attribute(:uploaded_file_options, {}) if uploaded_file_options.nil?
19
20
  uploaded_file_options[name] = opts
20
21
  self.send(:include, InstanceMethods)
22
+
21
23
  define_method(name) do
22
24
  attachments.find(:first, :conditions=>{:name => name.to_s})
23
25
  end
26
+
24
27
  define_method("#{name}=") do |new_file|
25
28
  raise InvalidFile unless (new_file.is_a?(File) || new_file.is_a?(Tempfile))
26
29
  uploaded_files[name] ||= {}
@@ -32,6 +35,10 @@ module Grip
32
35
 
33
36
  end
34
37
 
38
+ def set_callbacks_once
39
+ after_save :save_attachments unless after_save.collect(&:method).include?(:save_attachments)
40
+ end
41
+
35
42
  def uploaded_file_options
36
43
  read_inheritable_attribute(:uploaded_file_options)
37
44
  end
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.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - twoism
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-01-13 00:00:00 -05:00
13
+ date: 2010-01-15 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency