simply_stored 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +3 -0
- data/lib/simply_stored/couch/find_by.rb +114 -0
- data/lib/simply_stored/couch/finders.rb +56 -0
- data/lib/simply_stored/couch/has_many.rb +5 -3
- data/lib/simply_stored/couch.rb +5 -161
- data/lib/simply_stored/instance_methods.rb +4 -1
- data/lib/simply_stored.rb +1 -1
- data/test/fixtures/couch.rb +12 -0
- data/test/simply_stored_couch_test.rb +16 -0
- metadata +42 -21
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,114 @@
|
|
1
|
+
module SimplyStored
|
2
|
+
module Couch
|
3
|
+
module FindBy
|
4
|
+
def _define_find_by(name, *args)
|
5
|
+
keys = name.to_s.gsub(/^find_by_/, "").split("_and_")
|
6
|
+
view_name = name.to_s.gsub(/^find_/, "").to_sym
|
7
|
+
view_keys = keys.length == 1 ? keys.first : keys
|
8
|
+
without_deleted_view_name = "#{view_name}_withoutdeleted"
|
9
|
+
without_deleted_view_keys = keys + [:deleted_at]
|
10
|
+
|
11
|
+
unless respond_to?(view_name)
|
12
|
+
puts "Warning: Defining view #{self.name}##{view_name} with keys #{view_keys.inspect} at call time, please add it to the class body. (Called from #{caller[0]})"
|
13
|
+
view(view_name, :key => view_keys)
|
14
|
+
end
|
15
|
+
|
16
|
+
if !respond_to?(without_deleted_view_name) && soft_deleting_enabled?
|
17
|
+
puts "Warning: Defining view #{self.name}##{without_deleted_view_name} with keys #{without_deleted_view_keys.inspect} at call time, please add it to the class body. (Called from #{caller[0]})"
|
18
|
+
view(without_deleted_view_name, :key => without_deleted_view_keys)
|
19
|
+
end
|
20
|
+
|
21
|
+
(class << self; self end).instance_eval do
|
22
|
+
define_method(name) do |*key_args|
|
23
|
+
options = key_args.last.is_a?(Hash) ? key_args.pop : {}
|
24
|
+
options.assert_valid_keys(:with_deleted)
|
25
|
+
with_deleted = options.delete(:with_deleted)
|
26
|
+
|
27
|
+
raise ArgumentError, "Too many or too few arguments, require #{keys.inspect}" unless keys.size == key_args.size
|
28
|
+
|
29
|
+
if soft_deleting_enabled? && !with_deleted
|
30
|
+
key_args = key_args + [nil] # deleted_at
|
31
|
+
CouchPotato.database.view(send(without_deleted_view_name, :key => (key_args.size == 1 ? key_args.first : key_args), :limit => 1, :include_docs => true)).first
|
32
|
+
else
|
33
|
+
CouchPotato.database.view(send(view_name, :key => (key_args.size == 1 ? key_args.first : key_args), :limit => 1, :include_docs => true)).first
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
send(name, *args)
|
39
|
+
end
|
40
|
+
|
41
|
+
def _define_find_all_by(name, *args)
|
42
|
+
keys = name.to_s.gsub(/^find_all_by_/, "").split("_and_")
|
43
|
+
view_name = name.to_s.gsub(/^find_all_/, "").to_sym
|
44
|
+
view_keys = keys.length == 1 ? keys.first : keys
|
45
|
+
without_deleted_view_name = "#{view_name}_withoutdeleted"
|
46
|
+
without_deleted_view_keys = keys + [:deleted_at]
|
47
|
+
|
48
|
+
unless respond_to?(view_name)
|
49
|
+
puts "Warning: Defining view #{self.name}##{view_name} with keys #{view_keys.inspect} at call time, please add it to the class body. (Called from #{caller[0]})"
|
50
|
+
view(view_name, :key => view_keys)
|
51
|
+
end
|
52
|
+
|
53
|
+
if !respond_to?(without_deleted_view_name) && soft_deleting_enabled?
|
54
|
+
puts "Warning: Defining view #{self.name}##{without_deleted_view_name} with keys #{without_deleted_view_keys.inspect} at call time, please add it to the class body. (Called from #{caller[0]})"
|
55
|
+
view(without_deleted_view_name, :key => without_deleted_view_keys)
|
56
|
+
end
|
57
|
+
|
58
|
+
(class << self; self end).instance_eval do
|
59
|
+
define_method(name) do |*key_args|
|
60
|
+
options = key_args.last.is_a?(Hash) ? key_args.pop : {}
|
61
|
+
options.assert_valid_keys(:with_deleted)
|
62
|
+
with_deleted = options.delete(:with_deleted)
|
63
|
+
|
64
|
+
raise ArgumentError, "Too many or too few arguments, require #{keys.inspect}" unless keys.size == key_args.size
|
65
|
+
|
66
|
+
if soft_deleting_enabled? && !with_deleted
|
67
|
+
key_args = key_args + [nil] # deleted_at
|
68
|
+
CouchPotato.database.view(send(without_deleted_view_name, :key => (key_args.size == 1 ? key_args.first : key_args), :include_docs => true))
|
69
|
+
else
|
70
|
+
CouchPotato.database.view(send(view_name, :key => (key_args.size == 1 ? key_args.first : key_args), :include_docs => true))
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
send(name, *args)
|
75
|
+
end
|
76
|
+
|
77
|
+
def _define_count_by(name, *args)
|
78
|
+
keys = name.to_s.gsub(/^count_by_/, "").split("_and_")
|
79
|
+
view_name = name.to_s.gsub(/^count_/, "").to_sym
|
80
|
+
view_keys = keys.length == 1 ? keys.first : keys
|
81
|
+
without_deleted_view_name = "#{view_name}_withoutdeleted"
|
82
|
+
without_deleted_view_keys = keys + [:deleted_at]
|
83
|
+
|
84
|
+
unless respond_to?(view_name)
|
85
|
+
puts "Warning: Defining view #{self.name}##{view_name} with keys #{view_keys.inspect} at call time, please add it to the class body. (Called from #{caller[0]})"
|
86
|
+
view(view_name, :key => view_keys)
|
87
|
+
end
|
88
|
+
|
89
|
+
if !respond_to?(without_deleted_view_name) && soft_deleting_enabled?
|
90
|
+
puts "Warning: Defining view #{self.name}##{without_deleted_view_name} with keys #{without_deleted_view_keys.inspect} at call time, please add it to the class body. (Called from #{caller[0]})"
|
91
|
+
view(without_deleted_view_name, :key => without_deleted_view_keys)
|
92
|
+
end
|
93
|
+
|
94
|
+
(class << self; self end).instance_eval do
|
95
|
+
define_method("#{name}") do |*key_args|
|
96
|
+
options = key_args.last.is_a?(Hash) ? key_args.pop : {}
|
97
|
+
options.assert_valid_keys(:with_deleted)
|
98
|
+
with_deleted = options.delete(:with_deleted)
|
99
|
+
|
100
|
+
if soft_deleting_enabled? && !with_deleted
|
101
|
+
key_args = key_args + [nil] # deleted_at
|
102
|
+
CouchPotato.database.view(send(without_deleted_view_name, :key => (key_args.size == 1 ? key_args.first : key_args), :reduce => true))
|
103
|
+
else
|
104
|
+
CouchPotato.database.view(send(view_name, :key => (key_args.size == 1 ? key_args.first : key_args), :reduce => true))
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
send(name, *args)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module SimplyStored
|
2
|
+
module Couch
|
3
|
+
module Finders
|
4
|
+
def find(*args)
|
5
|
+
what = args.shift
|
6
|
+
options = args.last.is_a?(Hash) ? args.last : {}
|
7
|
+
if options && order = options.delete(:order)
|
8
|
+
options[:descending] = true if order == :desc
|
9
|
+
end
|
10
|
+
|
11
|
+
with_deleted = options.delete(:with_deleted)
|
12
|
+
|
13
|
+
case what
|
14
|
+
when :all
|
15
|
+
if with_deleted || !soft_deleting_enabled?
|
16
|
+
CouchPotato.database.view(all_documents(*args))
|
17
|
+
else
|
18
|
+
CouchPotato.database.view(all_documents_without_deleted(options.update(:key => nil)))
|
19
|
+
end
|
20
|
+
when :first
|
21
|
+
if with_deleted || !soft_deleting_enabled?
|
22
|
+
CouchPotato.database.view(all_documents(:limit => 1)).first
|
23
|
+
else
|
24
|
+
CouchPotato.database.view(all_documents_without_deleted(:key => nil, :limit => 1)).first
|
25
|
+
end
|
26
|
+
else
|
27
|
+
raise SimplyStored::Error, "Can't load record without an id" if what.nil?
|
28
|
+
document = CouchPotato.database.load_document(what)
|
29
|
+
if document.nil? or !document.is_a?(self) or (document.deleted? && !with_deleted)
|
30
|
+
raise(SimplyStored::RecordNotFound, "#{self.name} could not be found with #{what.inspect}")
|
31
|
+
end
|
32
|
+
document
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def all(*args)
|
37
|
+
find(:all, *args)
|
38
|
+
end
|
39
|
+
|
40
|
+
def first(*args)
|
41
|
+
find(:first, *args)
|
42
|
+
end
|
43
|
+
|
44
|
+
def count(options = {})
|
45
|
+
options.assert_valid_keys(:with_deleted)
|
46
|
+
with_deleted = options[:with_deleted]
|
47
|
+
|
48
|
+
if with_deleted || !soft_deleting_enabled?
|
49
|
+
CouchPotato.database.view(all_documents(:reduce => true))
|
50
|
+
else
|
51
|
+
CouchPotato.database.view(all_documents_without_deleted(:reduce => true, :key => nil))
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -84,12 +84,14 @@ module SimplyStored
|
|
84
84
|
klass = self.class.get_class_from_name(name)
|
85
85
|
raise ArgumentError, "expected #{klass} got #{value.class}" unless value.is_a?(klass)
|
86
86
|
raise ArgumentError, "cannot remove not mine" unless value.send(self.class.foreign_key.to_sym) == id
|
87
|
-
|
87
|
+
|
88
88
|
if self.class._find_property(name).options[:dependent] == :destroy
|
89
89
|
value.destroy
|
90
|
-
|
90
|
+
elsif self.class._find_property(name).options[:dependent] == :ignore
|
91
|
+
# skip
|
92
|
+
else # nullify
|
91
93
|
value.send("#{self.class.foreign_key}=", nil)
|
92
|
-
value.save
|
94
|
+
value.save(false)
|
93
95
|
end
|
94
96
|
|
95
97
|
cached_results = send("_get_cached_#{name}")[:all]
|
data/lib/simply_stored/couch.rb
CHANGED
@@ -4,6 +4,8 @@ require 'active_support'
|
|
4
4
|
|
5
5
|
require File.expand_path(File.dirname(__FILE__) + '/../simply_stored')
|
6
6
|
require 'simply_stored/couch/validations'
|
7
|
+
require 'simply_stored/couch/finders'
|
8
|
+
require 'simply_stored/couch/find_by'
|
7
9
|
require 'simply_stored/couch/belongs_to'
|
8
10
|
require 'simply_stored/couch/has_many'
|
9
11
|
require 'simply_stored/couch/has_one'
|
@@ -34,6 +36,8 @@ module SimplyStored
|
|
34
36
|
include SimplyStored::Couch::BelongsTo
|
35
37
|
include SimplyStored::Couch::HasMany
|
36
38
|
include SimplyStored::Couch::HasOne
|
39
|
+
include SimplyStored::Couch::Finders
|
40
|
+
include SimplyStored::Couch::FindBy
|
37
41
|
include SimplyStored::Storage::ClassMethods
|
38
42
|
|
39
43
|
def create(attributes = {}, &blk)
|
@@ -48,57 +52,6 @@ module SimplyStored
|
|
48
52
|
instance
|
49
53
|
end
|
50
54
|
|
51
|
-
def find(*args)
|
52
|
-
what = args.shift
|
53
|
-
options = args.last.is_a?(Hash) ? args.last : {}
|
54
|
-
if options && order = options.delete(:order)
|
55
|
-
options[:descending] = true if order == :desc
|
56
|
-
end
|
57
|
-
|
58
|
-
with_deleted = options.delete(:with_deleted)
|
59
|
-
|
60
|
-
case what
|
61
|
-
when :all
|
62
|
-
if with_deleted || !soft_deleting_enabled?
|
63
|
-
CouchPotato.database.view(all_documents(*args))
|
64
|
-
else
|
65
|
-
CouchPotato.database.view(all_documents_without_deleted(options.update(:key => nil)))
|
66
|
-
end
|
67
|
-
when :first
|
68
|
-
if with_deleted || !soft_deleting_enabled?
|
69
|
-
CouchPotato.database.view(all_documents(:limit => 1)).first
|
70
|
-
else
|
71
|
-
CouchPotato.database.view(all_documents_without_deleted(:key => nil, :limit => 1)).first
|
72
|
-
end
|
73
|
-
else
|
74
|
-
raise SimplyStored::Error, "Can't load record without an id" if what.nil?
|
75
|
-
document = CouchPotato.database.load_document(what)
|
76
|
-
if document.nil? or !document.is_a?(self) or (document.deleted? && !with_deleted)
|
77
|
-
raise(SimplyStored::RecordNotFound, "#{self.name} could not be found with #{what.inspect}")
|
78
|
-
end
|
79
|
-
document
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def all(*args)
|
84
|
-
find(:all, *args)
|
85
|
-
end
|
86
|
-
|
87
|
-
def first(*args)
|
88
|
-
find(:first, *args)
|
89
|
-
end
|
90
|
-
|
91
|
-
def count(options = {})
|
92
|
-
options.assert_valid_keys(:with_deleted)
|
93
|
-
with_deleted = options[:with_deleted]
|
94
|
-
|
95
|
-
if with_deleted || !soft_deleting_enabled?
|
96
|
-
CouchPotato.database.view(all_documents(:reduce => true))
|
97
|
-
else
|
98
|
-
CouchPotato.database.view(all_documents_without_deleted(:reduce => true, :key => nil))
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
55
|
def enable_soft_delete(property_name = :deleted_at)
|
103
56
|
@_soft_delete_attribute = property_name.to_sym
|
104
57
|
property property_name, :type => Time
|
@@ -149,116 +102,7 @@ module SimplyStored
|
|
149
102
|
options.update(:with => valid_regex)
|
150
103
|
validates_format_of(attr, options)
|
151
104
|
end
|
152
|
-
|
153
|
-
def _define_find_by(name, *args)
|
154
|
-
keys = name.to_s.gsub(/^find_by_/, "").split("_and_")
|
155
|
-
view_name = name.to_s.gsub(/^find_/, "").to_sym
|
156
|
-
view_keys = keys.length == 1 ? keys.first : keys
|
157
|
-
without_deleted_view_name = "#{view_name}_withoutdeleted"
|
158
|
-
without_deleted_view_keys = keys + [:deleted_at]
|
159
|
-
|
160
|
-
unless respond_to?(view_name)
|
161
|
-
puts "Warning: Defining view #{self.name}##{view_name} with keys #{view_keys.inspect} at call time, please add it to the class body. (Called from #{caller[0]})"
|
162
|
-
view(view_name, :key => view_keys)
|
163
|
-
end
|
164
|
-
|
165
|
-
if !respond_to?(without_deleted_view_name) && soft_deleting_enabled?
|
166
|
-
puts "Warning: Defining view #{self.name}##{without_deleted_view_name} with keys #{without_deleted_view_keys.inspect} at call time, please add it to the class body. (Called from #{caller[0]})"
|
167
|
-
view(without_deleted_view_name, :key => without_deleted_view_keys)
|
168
|
-
end
|
169
|
-
|
170
|
-
(class << self; self end).instance_eval do
|
171
|
-
define_method(name) do |*key_args|
|
172
|
-
options = key_args.last.is_a?(Hash) ? key_args.pop : {}
|
173
|
-
options.assert_valid_keys(:with_deleted)
|
174
|
-
with_deleted = options.delete(:with_deleted)
|
175
|
-
|
176
|
-
raise ArgumentError, "Too many or too few arguments, require #{keys.inspect}" unless keys.size == key_args.size
|
177
|
-
|
178
|
-
if soft_deleting_enabled? && !with_deleted
|
179
|
-
key_args = key_args + [nil] # deleted_at
|
180
|
-
CouchPotato.database.view(send(without_deleted_view_name, :key => (key_args.size == 1 ? key_args.first : key_args), :limit => 1, :include_docs => true)).first
|
181
|
-
else
|
182
|
-
CouchPotato.database.view(send(view_name, :key => (key_args.size == 1 ? key_args.first : key_args), :limit => 1, :include_docs => true)).first
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
send(name, *args)
|
188
|
-
end
|
189
|
-
|
190
|
-
def _define_find_all_by(name, *args)
|
191
|
-
keys = name.to_s.gsub(/^find_all_by_/, "").split("_and_")
|
192
|
-
view_name = name.to_s.gsub(/^find_all_/, "").to_sym
|
193
|
-
view_keys = keys.length == 1 ? keys.first : keys
|
194
|
-
without_deleted_view_name = "#{view_name}_withoutdeleted"
|
195
|
-
without_deleted_view_keys = keys + [:deleted_at]
|
196
|
-
|
197
|
-
unless respond_to?(view_name)
|
198
|
-
puts "Warning: Defining view #{self.name}##{view_name} with keys #{view_keys.inspect} at call time, please add it to the class body. (Called from #{caller[0]})"
|
199
|
-
view(view_name, :key => view_keys)
|
200
|
-
end
|
201
|
-
|
202
|
-
if !respond_to?(without_deleted_view_name) && soft_deleting_enabled?
|
203
|
-
puts "Warning: Defining view #{self.name}##{without_deleted_view_name} with keys #{without_deleted_view_keys.inspect} at call time, please add it to the class body. (Called from #{caller[0]})"
|
204
|
-
view(without_deleted_view_name, :key => without_deleted_view_keys)
|
205
|
-
end
|
206
|
-
|
207
|
-
(class << self; self end).instance_eval do
|
208
|
-
define_method(name) do |*key_args|
|
209
|
-
options = key_args.last.is_a?(Hash) ? key_args.pop : {}
|
210
|
-
options.assert_valid_keys(:with_deleted)
|
211
|
-
with_deleted = options.delete(:with_deleted)
|
212
|
-
|
213
|
-
raise ArgumentError, "Too many or too few arguments, require #{keys.inspect}" unless keys.size == key_args.size
|
214
|
-
|
215
|
-
if soft_deleting_enabled? && !with_deleted
|
216
|
-
key_args = key_args + [nil] # deleted_at
|
217
|
-
CouchPotato.database.view(send(without_deleted_view_name, :key => (key_args.size == 1 ? key_args.first : key_args), :include_docs => true))
|
218
|
-
else
|
219
|
-
CouchPotato.database.view(send(view_name, :key => (key_args.size == 1 ? key_args.first : key_args), :include_docs => true))
|
220
|
-
end
|
221
|
-
end
|
222
|
-
end
|
223
|
-
send(name, *args)
|
224
|
-
end
|
225
|
-
|
226
|
-
def _define_count_by(name, *args)
|
227
|
-
keys = name.to_s.gsub(/^count_by_/, "").split("_and_")
|
228
|
-
view_name = name.to_s.gsub(/^count_/, "").to_sym
|
229
|
-
view_keys = keys.length == 1 ? keys.first : keys
|
230
|
-
without_deleted_view_name = "#{view_name}_withoutdeleted"
|
231
|
-
without_deleted_view_keys = keys + [:deleted_at]
|
232
|
-
|
233
|
-
unless respond_to?(view_name)
|
234
|
-
puts "Warning: Defining view #{self.name}##{view_name} with keys #{view_keys.inspect} at call time, please add it to the class body. (Called from #{caller[0]})"
|
235
|
-
view(view_name, :key => view_keys)
|
236
|
-
end
|
237
|
-
|
238
|
-
if !respond_to?(without_deleted_view_name) && soft_deleting_enabled?
|
239
|
-
puts "Warning: Defining view #{self.name}##{without_deleted_view_name} with keys #{without_deleted_view_keys.inspect} at call time, please add it to the class body. (Called from #{caller[0]})"
|
240
|
-
view(without_deleted_view_name, :key => without_deleted_view_keys)
|
241
|
-
end
|
242
|
-
|
243
|
-
(class << self; self end).instance_eval do
|
244
|
-
define_method("#{name}") do |*key_args|
|
245
|
-
options = key_args.last.is_a?(Hash) ? key_args.pop : {}
|
246
|
-
options.assert_valid_keys(:with_deleted)
|
247
|
-
with_deleted = options.delete(:with_deleted)
|
248
|
-
|
249
|
-
if soft_deleting_enabled? && !with_deleted
|
250
|
-
key_args = key_args + [nil] # deleted_at
|
251
|
-
CouchPotato.database.view(send(without_deleted_view_name, :key => (key_args.size == 1 ? key_args.first : key_args), :reduce => true))
|
252
|
-
else
|
253
|
-
CouchPotato.database.view(send(view_name, :key => (key_args.size == 1 ? key_args.first : key_args), :reduce => true))
|
254
|
-
end
|
255
|
-
|
256
|
-
end
|
257
|
-
end
|
258
|
-
|
259
|
-
send(name, *args)
|
260
|
-
end
|
261
|
-
|
105
|
+
|
262
106
|
def method_missing(name, *args)
|
263
107
|
if name.to_s =~ /^find_by/
|
264
108
|
_define_find_by(name, *args)
|
@@ -152,7 +152,10 @@ module SimplyStored
|
|
152
152
|
case property.options[:dependent]
|
153
153
|
when :destroy
|
154
154
|
dependent.destroy
|
155
|
-
|
155
|
+
when :ignore
|
156
|
+
# skip
|
157
|
+
else
|
158
|
+
# nullify
|
156
159
|
unless dependent.class.soft_deleting_enabled?
|
157
160
|
dependent.send("#{self.class.foreign_property}=", nil)
|
158
161
|
dependent.save(false)
|
data/lib/simply_stored.rb
CHANGED
@@ -4,7 +4,7 @@ require File.expand_path(File.dirname(__FILE__) + '/simply_stored/storage')
|
|
4
4
|
require File.expand_path(File.dirname(__FILE__) + '/simply_stored/class_methods_base')
|
5
5
|
|
6
6
|
module SimplyStored
|
7
|
-
VERSION = '0.3.
|
7
|
+
VERSION = '0.3.2'
|
8
8
|
class Error < RuntimeError; end
|
9
9
|
class RecordNotFound < RuntimeError; end
|
10
10
|
end
|
data/test/fixtures/couch.rb
CHANGED
@@ -179,4 +179,16 @@ class Spot
|
|
179
179
|
include SimplyStored::Couch
|
180
180
|
|
181
181
|
has_one :hemorrhoid
|
182
|
+
end
|
183
|
+
|
184
|
+
class Master
|
185
|
+
include SimplyStored::Couch
|
186
|
+
|
187
|
+
has_many :servants, :dependent => :ignore
|
188
|
+
end
|
189
|
+
|
190
|
+
class Servant
|
191
|
+
include SimplyStored::Couch
|
192
|
+
|
193
|
+
belongs_to :master
|
182
194
|
end
|
@@ -700,6 +700,22 @@ class CouchTest < Test::Unit::TestCase
|
|
700
700
|
assert_equal [], Tag.find(:all)
|
701
701
|
end
|
702
702
|
|
703
|
+
should "not nullify or delete dependents if the options is set to :ignore when removing" do
|
704
|
+
master = Master.create
|
705
|
+
master_id = master.id
|
706
|
+
servant = Servant.create(:master => master)
|
707
|
+
master.remove_servant(servant)
|
708
|
+
assert_equal master_id, servant.reload.master_id
|
709
|
+
end
|
710
|
+
|
711
|
+
should "not nullify or delete dependents if the options is set to :ignore when deleting" do
|
712
|
+
master = Master.create
|
713
|
+
master_id = master.id
|
714
|
+
servant = Servant.create(:master => master)
|
715
|
+
master.destroy
|
716
|
+
assert_equal master_id, servant.reload.master_id
|
717
|
+
end
|
718
|
+
|
703
719
|
end
|
704
720
|
|
705
721
|
context "when removing all items" do
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simply_stored
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 3
|
8
|
+
- 2
|
9
|
+
version: 0.3.2
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Mathias Meyer, Jonathan Weiss
|
@@ -9,49 +14,61 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-14 00:00:00 +02:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: rest-client
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 4
|
30
|
+
- 2
|
23
31
|
version: 1.4.2
|
24
|
-
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
25
34
|
- !ruby/object:Gem::Dependency
|
26
35
|
name: couch_potato
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
38
|
requirements:
|
31
39
|
- - ">="
|
32
40
|
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
- 2
|
44
|
+
- 15
|
33
45
|
version: 0.2.15
|
34
|
-
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
35
48
|
- !ruby/object:Gem::Dependency
|
36
49
|
name: activesupport
|
37
|
-
|
38
|
-
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
52
|
requirements:
|
41
53
|
- - ">="
|
42
54
|
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 0
|
43
57
|
version: "0"
|
44
|
-
|
58
|
+
type: :runtime
|
59
|
+
version_requirements: *id003
|
45
60
|
- !ruby/object:Gem::Dependency
|
46
61
|
name: mattmatt-validatable
|
47
|
-
|
48
|
-
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
64
|
requirements:
|
51
65
|
- - ">="
|
52
66
|
- !ruby/object:Gem::Version
|
67
|
+
segments:
|
68
|
+
- 0
|
53
69
|
version: "0"
|
54
|
-
|
70
|
+
type: :runtime
|
71
|
+
version_requirements: *id004
|
55
72
|
description: Convenience layer for CouchDB and SimpleDB. Requires CouchPotato and RightAWS library respectively.
|
56
73
|
email: info@peritor.com
|
57
74
|
executables: []
|
@@ -70,6 +87,8 @@ files:
|
|
70
87
|
- lib/simply_stored/couch.rb
|
71
88
|
- lib/simply_stored/couch/belongs_to.rb
|
72
89
|
- lib/simply_stored/couch/ext/couch_potato.rb
|
90
|
+
- lib/simply_stored/couch/find_by.rb
|
91
|
+
- lib/simply_stored/couch/finders.rb
|
73
92
|
- lib/simply_stored/couch/has_many.rb
|
74
93
|
- lib/simply_stored/couch/has_one.rb
|
75
94
|
- lib/simply_stored/couch/validations.rb
|
@@ -96,18 +115,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
115
|
requirements:
|
97
116
|
- - ">="
|
98
117
|
- !ruby/object:Gem::Version
|
118
|
+
segments:
|
119
|
+
- 0
|
99
120
|
version: "0"
|
100
|
-
version:
|
101
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
122
|
requirements:
|
103
123
|
- - ">="
|
104
124
|
- !ruby/object:Gem::Version
|
125
|
+
segments:
|
126
|
+
- 0
|
105
127
|
version: "0"
|
106
|
-
version:
|
107
128
|
requirements: []
|
108
129
|
|
109
130
|
rubyforge_project:
|
110
|
-
rubygems_version: 1.3.
|
131
|
+
rubygems_version: 1.3.6
|
111
132
|
signing_key:
|
112
133
|
specification_version: 3
|
113
134
|
summary: Convenience layer for CouchDB and SimpleDB
|