mongo_mapper_ign 0.7.7 → 0.7.8
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/LICENSE +20 -20
- data/README.rdoc +34 -34
- data/bin/mmconsole +60 -60
- data/lib/mongo_mapper.rb +123 -123
- data/lib/mongo_mapper/document.rb +292 -292
- data/lib/mongo_mapper/embedded_document.rb +71 -71
- data/lib/mongo_mapper/plugins.rb +36 -36
- data/lib/mongo_mapper/plugins/associations.rb +115 -115
- data/lib/mongo_mapper/plugins/associations/base.rb +124 -124
- data/lib/mongo_mapper/plugins/associations/belongs_to_polymorphic_proxy.rb +31 -31
- data/lib/mongo_mapper/plugins/associations/belongs_to_proxy.rb +26 -26
- data/lib/mongo_mapper/plugins/associations/collection.rb +21 -21
- data/lib/mongo_mapper/plugins/associations/embedded_collection.rb +39 -39
- data/lib/mongo_mapper/plugins/associations/in_array_proxy.rb +160 -144
- data/lib/mongo_mapper/plugins/associations/many_documents_as_proxy.rb +29 -29
- data/lib/mongo_mapper/plugins/associations/many_documents_proxy.rb +130 -130
- data/lib/mongo_mapper/plugins/associations/many_embedded_polymorphic_proxy.rb +32 -32
- data/lib/mongo_mapper/plugins/associations/many_embedded_proxy.rb +24 -24
- data/lib/mongo_mapper/plugins/associations/many_polymorphic_proxy.rb +14 -14
- data/lib/mongo_mapper/plugins/associations/one_embedded_proxy.rb +42 -42
- data/lib/mongo_mapper/plugins/associations/one_proxy.rb +70 -70
- data/lib/mongo_mapper/plugins/associations/proxy.rb +125 -125
- data/lib/mongo_mapper/plugins/callbacks.rb +241 -241
- data/lib/mongo_mapper/plugins/clone.rb +13 -13
- data/lib/mongo_mapper/plugins/descendants.rb +16 -16
- data/lib/mongo_mapper/plugins/dirty.rb +119 -119
- data/lib/mongo_mapper/plugins/equality.rb +23 -23
- data/lib/mongo_mapper/plugins/identity_map.rb +123 -123
- data/lib/mongo_mapper/plugins/inspect.rb +14 -14
- data/lib/mongo_mapper/plugins/keys.rb +322 -322
- data/lib/mongo_mapper/plugins/keys/key.rb +53 -53
- data/lib/mongo_mapper/plugins/logger.rb +17 -17
- data/lib/mongo_mapper/plugins/modifiers.rb +111 -111
- data/lib/mongo_mapper/plugins/pagination.rb +24 -24
- data/lib/mongo_mapper/plugins/pagination/proxy.rb +72 -72
- data/lib/mongo_mapper/plugins/persistence.rb +96 -96
- data/lib/mongo_mapper/plugins/protected.rb +46 -46
- data/lib/mongo_mapper/plugins/rails.rb +57 -57
- data/lib/mongo_mapper/plugins/serialization.rb +92 -92
- data/lib/mongo_mapper/plugins/serialization/array.rb +56 -56
- data/lib/mongo_mapper/plugins/serialization/xml_serializer.rb +239 -239
- data/lib/mongo_mapper/plugins/timestamps.rb +21 -21
- data/lib/mongo_mapper/plugins/userstamps.rb +14 -14
- data/lib/mongo_mapper/plugins/validations.rb +46 -46
- data/lib/mongo_mapper/query.rb +28 -28
- data/lib/mongo_mapper/support.rb +197 -197
- data/lib/mongo_mapper/support/descendant_appends.rb +46 -46
- data/lib/mongo_mapper/support/find.rb +77 -77
- data/lib/mongo_mapper/version.rb +3 -3
- metadata +4 -25
@@ -1,47 +1,47 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
module MongoMapper
|
3
|
-
module Support
|
4
|
-
module DescendantAppends
|
5
|
-
def included(model)
|
6
|
-
extra_extensions.each { |extension| model.extend(extension) }
|
7
|
-
extra_inclusions.each { |inclusion| model.send(:include, inclusion) }
|
8
|
-
descendants << model
|
9
|
-
end
|
10
|
-
|
11
|
-
# @api public
|
12
|
-
def descendants
|
13
|
-
@descendants ||= Set.new
|
14
|
-
end
|
15
|
-
|
16
|
-
# @api public
|
17
|
-
def append_extensions(*extensions)
|
18
|
-
extra_extensions.concat extensions
|
19
|
-
|
20
|
-
# Add the extension to existing descendants
|
21
|
-
descendants.each do |model|
|
22
|
-
extensions.each { |extension| model.extend(extension) }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# @api public
|
27
|
-
def append_inclusions(*inclusions)
|
28
|
-
extra_inclusions.concat inclusions
|
29
|
-
|
30
|
-
# Add the inclusion to existing descendants
|
31
|
-
descendants.each do |model|
|
32
|
-
inclusions.each { |inclusion| model.send(:include, inclusion) }
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# @api private
|
37
|
-
def extra_extensions
|
38
|
-
@extra_extensions ||= []
|
39
|
-
end
|
40
|
-
|
41
|
-
# @api private
|
42
|
-
def extra_inclusions
|
43
|
-
@extra_inclusions ||= []
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
module MongoMapper
|
3
|
+
module Support
|
4
|
+
module DescendantAppends
|
5
|
+
def included(model)
|
6
|
+
extra_extensions.each { |extension| model.extend(extension) }
|
7
|
+
extra_inclusions.each { |inclusion| model.send(:include, inclusion) }
|
8
|
+
descendants << model
|
9
|
+
end
|
10
|
+
|
11
|
+
# @api public
|
12
|
+
def descendants
|
13
|
+
@descendants ||= Set.new
|
14
|
+
end
|
15
|
+
|
16
|
+
# @api public
|
17
|
+
def append_extensions(*extensions)
|
18
|
+
extra_extensions.concat extensions
|
19
|
+
|
20
|
+
# Add the extension to existing descendants
|
21
|
+
descendants.each do |model|
|
22
|
+
extensions.each { |extension| model.extend(extension) }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# @api public
|
27
|
+
def append_inclusions(*inclusions)
|
28
|
+
extra_inclusions.concat inclusions
|
29
|
+
|
30
|
+
# Add the inclusion to existing descendants
|
31
|
+
descendants.each do |model|
|
32
|
+
inclusions.each { |inclusion| model.send(:include, inclusion) }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# @api private
|
37
|
+
def extra_extensions
|
38
|
+
@extra_extensions ||= []
|
39
|
+
end
|
40
|
+
|
41
|
+
# @api private
|
42
|
+
def extra_inclusions
|
43
|
+
@extra_inclusions ||= []
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
47
|
end
|
@@ -1,78 +1,78 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
module MongoMapper
|
3
|
-
module Support
|
4
|
-
# @api private
|
5
|
-
module Find
|
6
|
-
def dynamic_find(finder, args)
|
7
|
-
attributes = {}
|
8
|
-
|
9
|
-
finder.attributes.each_with_index do |attr, index|
|
10
|
-
attributes[attr] = args[index]
|
11
|
-
end
|
12
|
-
|
13
|
-
options = args.extract_options!.merge(attributes)
|
14
|
-
|
15
|
-
if result = send(finder.finder, options)
|
16
|
-
result
|
17
|
-
else
|
18
|
-
if finder.raise?
|
19
|
-
raise DocumentNotFound, "Couldn't find Document with #{attributes.inspect} in collection named #{collection.name}"
|
20
|
-
end
|
21
|
-
|
22
|
-
if finder.instantiator
|
23
|
-
self.send(finder.instantiator, attributes)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class DynamicFinder
|
29
|
-
attr_reader :method, :attributes, :finder, :bang, :instantiator
|
30
|
-
|
31
|
-
def initialize(method)
|
32
|
-
@method = method
|
33
|
-
@finder = :first
|
34
|
-
@bang = false
|
35
|
-
match
|
36
|
-
end
|
37
|
-
|
38
|
-
def found?
|
39
|
-
@finder.present?
|
40
|
-
end
|
41
|
-
|
42
|
-
def raise?
|
43
|
-
bang == true
|
44
|
-
end
|
45
|
-
|
46
|
-
protected
|
47
|
-
def match
|
48
|
-
case method.to_s
|
49
|
-
when /^find_(all_by|by)_([_a-zA-Z]\w*)$/
|
50
|
-
@finder = :all if $1 == 'all_by'
|
51
|
-
names = $2
|
52
|
-
when /^find_by_([_a-zA-Z]\w*)\!$/
|
53
|
-
@bang = true
|
54
|
-
names = $1
|
55
|
-
when /^find_or_(initialize|create)_by_([_a-zA-Z]\w*)$/
|
56
|
-
@instantiator = $1 == 'initialize' ? :new : :create
|
57
|
-
names = $2
|
58
|
-
else
|
59
|
-
@finder = nil
|
60
|
-
end
|
61
|
-
|
62
|
-
@attributes = names && names.split('_and_')
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
protected
|
67
|
-
def method_missing(method, *args, &block)
|
68
|
-
finder = DynamicFinder.new(method)
|
69
|
-
|
70
|
-
if finder.found?
|
71
|
-
dynamic_find(finder, args)
|
72
|
-
else
|
73
|
-
super
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
module MongoMapper
|
3
|
+
module Support
|
4
|
+
# @api private
|
5
|
+
module Find
|
6
|
+
def dynamic_find(finder, args)
|
7
|
+
attributes = {}
|
8
|
+
|
9
|
+
finder.attributes.each_with_index do |attr, index|
|
10
|
+
attributes[attr] = args[index]
|
11
|
+
end
|
12
|
+
|
13
|
+
options = args.extract_options!.merge(attributes)
|
14
|
+
|
15
|
+
if result = send(finder.finder, options)
|
16
|
+
result
|
17
|
+
else
|
18
|
+
if finder.raise?
|
19
|
+
raise DocumentNotFound, "Couldn't find Document with #{attributes.inspect} in collection named #{collection.name}"
|
20
|
+
end
|
21
|
+
|
22
|
+
if finder.instantiator
|
23
|
+
self.send(finder.instantiator, attributes)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class DynamicFinder
|
29
|
+
attr_reader :method, :attributes, :finder, :bang, :instantiator
|
30
|
+
|
31
|
+
def initialize(method)
|
32
|
+
@method = method
|
33
|
+
@finder = :first
|
34
|
+
@bang = false
|
35
|
+
match
|
36
|
+
end
|
37
|
+
|
38
|
+
def found?
|
39
|
+
@finder.present?
|
40
|
+
end
|
41
|
+
|
42
|
+
def raise?
|
43
|
+
bang == true
|
44
|
+
end
|
45
|
+
|
46
|
+
protected
|
47
|
+
def match
|
48
|
+
case method.to_s
|
49
|
+
when /^find_(all_by|by)_([_a-zA-Z]\w*)$/
|
50
|
+
@finder = :all if $1 == 'all_by'
|
51
|
+
names = $2
|
52
|
+
when /^find_by_([_a-zA-Z]\w*)\!$/
|
53
|
+
@bang = true
|
54
|
+
names = $1
|
55
|
+
when /^find_or_(initialize|create)_by_([_a-zA-Z]\w*)$/
|
56
|
+
@instantiator = $1 == 'initialize' ? :new : :create
|
57
|
+
names = $2
|
58
|
+
else
|
59
|
+
@finder = nil
|
60
|
+
end
|
61
|
+
|
62
|
+
@attributes = names && names.split('_and_')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
protected
|
67
|
+
def method_missing(method, *args, &block)
|
68
|
+
finder = DynamicFinder.new(method)
|
69
|
+
|
70
|
+
if finder.found?
|
71
|
+
dynamic_find(finder, args)
|
72
|
+
else
|
73
|
+
super
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
78
|
end
|
data/lib/mongo_mapper/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
module MongoMapper
|
3
|
-
Version = '0.7.
|
1
|
+
# encoding: UTF-8
|
2
|
+
module MongoMapper
|
3
|
+
Version = '0.7.8'
|
4
4
|
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo_mapper_ign
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 13
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
8
|
+
- 8
|
9
|
+
version: 0.7.8
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- John Nunemaker
|
@@ -17,18 +16,16 @@ autorequire:
|
|
17
16
|
bindir: bin
|
18
17
|
cert_chain: []
|
19
18
|
|
20
|
-
date: 2010-
|
19
|
+
date: 2010-07-21 00:00:00 -07:00
|
21
20
|
default_executable: mmconsole
|
22
21
|
dependencies:
|
23
22
|
- !ruby/object:Gem::Dependency
|
24
23
|
name: activesupport
|
25
24
|
prerelease: false
|
26
25
|
requirement: &id001 !ruby/object:Gem::Requirement
|
27
|
-
none: false
|
28
26
|
requirements:
|
29
27
|
- - ">="
|
30
28
|
- !ruby/object:Gem::Version
|
31
|
-
hash: 11
|
32
29
|
segments:
|
33
30
|
- 2
|
34
31
|
- 3
|
@@ -40,11 +37,9 @@ dependencies:
|
|
40
37
|
name: jnunemaker-validatable
|
41
38
|
prerelease: false
|
42
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
40
|
requirements:
|
45
41
|
- - "="
|
46
42
|
- !ruby/object:Gem::Version
|
47
|
-
hash: 63
|
48
43
|
segments:
|
49
44
|
- 1
|
50
45
|
- 8
|
@@ -56,11 +51,9 @@ dependencies:
|
|
56
51
|
name: plucky
|
57
52
|
prerelease: false
|
58
53
|
requirement: &id003 !ruby/object:Gem::Requirement
|
59
|
-
none: false
|
60
54
|
requirements:
|
61
55
|
- - "="
|
62
56
|
- !ruby/object:Gem::Version
|
63
|
-
hash: 31
|
64
57
|
segments:
|
65
58
|
- 0
|
66
59
|
- 1
|
@@ -72,11 +65,9 @@ dependencies:
|
|
72
65
|
name: json
|
73
66
|
prerelease: false
|
74
67
|
requirement: &id004 !ruby/object:Gem::Requirement
|
75
|
-
none: false
|
76
68
|
requirements:
|
77
69
|
- - ">="
|
78
70
|
- !ruby/object:Gem::Version
|
79
|
-
hash: 25
|
80
71
|
segments:
|
81
72
|
- 1
|
82
73
|
- 2
|
@@ -88,11 +79,9 @@ dependencies:
|
|
88
79
|
name: jnunemaker-matchy
|
89
80
|
prerelease: false
|
90
81
|
requirement: &id005 !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
82
|
requirements:
|
93
83
|
- - "="
|
94
84
|
- !ruby/object:Gem::Version
|
95
|
-
hash: 15
|
96
85
|
segments:
|
97
86
|
- 0
|
98
87
|
- 4
|
@@ -104,11 +93,9 @@ dependencies:
|
|
104
93
|
name: shoulda
|
105
94
|
prerelease: false
|
106
95
|
requirement: &id006 !ruby/object:Gem::Requirement
|
107
|
-
none: false
|
108
96
|
requirements:
|
109
97
|
- - "="
|
110
98
|
- !ruby/object:Gem::Version
|
111
|
-
hash: 35
|
112
99
|
segments:
|
113
100
|
- 2
|
114
101
|
- 10
|
@@ -120,11 +107,9 @@ dependencies:
|
|
120
107
|
name: timecop
|
121
108
|
prerelease: false
|
122
109
|
requirement: &id007 !ruby/object:Gem::Requirement
|
123
|
-
none: false
|
124
110
|
requirements:
|
125
111
|
- - "="
|
126
112
|
- !ruby/object:Gem::Version
|
127
|
-
hash: 17
|
128
113
|
segments:
|
129
114
|
- 0
|
130
115
|
- 3
|
@@ -136,11 +121,9 @@ dependencies:
|
|
136
121
|
name: mocha
|
137
122
|
prerelease: false
|
138
123
|
requirement: &id008 !ruby/object:Gem::Requirement
|
139
|
-
none: false
|
140
124
|
requirements:
|
141
125
|
- - "="
|
142
126
|
- !ruby/object:Gem::Version
|
143
|
-
hash: 43
|
144
127
|
segments:
|
145
128
|
- 0
|
146
129
|
- 9
|
@@ -216,20 +199,16 @@ rdoc_options: []
|
|
216
199
|
require_paths:
|
217
200
|
- lib
|
218
201
|
required_ruby_version: !ruby/object:Gem::Requirement
|
219
|
-
none: false
|
220
202
|
requirements:
|
221
203
|
- - ">="
|
222
204
|
- !ruby/object:Gem::Version
|
223
|
-
hash: 3
|
224
205
|
segments:
|
225
206
|
- 0
|
226
207
|
version: "0"
|
227
208
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
|
-
none: false
|
229
209
|
requirements:
|
230
210
|
- - ">="
|
231
211
|
- !ruby/object:Gem::Version
|
232
|
-
hash: 23
|
233
212
|
segments:
|
234
213
|
- 1
|
235
214
|
- 3
|
@@ -238,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
238
217
|
requirements: []
|
239
218
|
|
240
219
|
rubyforge_project:
|
241
|
-
rubygems_version: 1.3.
|
220
|
+
rubygems_version: 1.3.6
|
242
221
|
signing_key:
|
243
222
|
specification_version: 3
|
244
223
|
summary: A Ruby Object Mapper for Mongo
|