mm-files 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/mm-files.rb +1 -1
- data/lib/mm-files/file.rb +1 -1
- data/lib/mm-files/files.rb +4 -4
- metadata +2 -2
data/lib/mm-files.rb
CHANGED
data/lib/mm-files/file.rb
CHANGED
@@ -23,7 +23,7 @@ module MongoMapper
|
|
23
23
|
|
24
24
|
def self.fetch(owner, filename)
|
25
25
|
db = owner.class.database
|
26
|
-
criteria, options = FinderOptions.new(:filename => filename, :metadata => owner.id, :limit => 1).to_a
|
26
|
+
criteria, options = FinderOptions.new(:filename => filename, :metadata => {:_id => owner.id}, :limit => 1).to_a
|
27
27
|
|
28
28
|
obj = db.collection("#{owner.collection.name}.files").find(criteria, options).next_object
|
29
29
|
if obj
|
data/lib/mm-files/files.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
module MongoMapper
|
2
2
|
module Files
|
3
|
-
def self.included
|
3
|
+
def self.included(model)
|
4
4
|
model.class_eval do
|
5
5
|
after_create :_sync_pending_files
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
|
-
def put_file(filename, data)
|
9
|
+
def put_file(filename, data, metadata = {})
|
10
10
|
if !new?
|
11
11
|
XGen::Mongo::GridFS::GridStore.open(self.class.database, filename, "w",
|
12
12
|
:root => self.collection.name,
|
13
|
-
:metadata => self.id) do |f|
|
13
|
+
:metadata => metadata.deep_merge({:_id => self.id})) do |f|
|
14
14
|
f << data
|
15
15
|
end
|
16
16
|
else
|
@@ -23,7 +23,7 @@ module MongoMapper
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def files
|
26
|
-
criteria, options = FinderOptions.new(:metadata => self.id).to_a
|
26
|
+
criteria, options = FinderOptions.new(:metadata => {:_id => self.id}).to_a
|
27
27
|
coll = self.class.database.collection("#{self.collection.name}.files")
|
28
28
|
@files = coll.find(criteria, options).map do |a|
|
29
29
|
MongoMapper::File.new(self, a)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mm-files
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cuadrado
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-18 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|