ripple 0.9.5 → 1.0.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +32 -0
- data/Gemfile +10 -9
- data/Guardfile +15 -0
- data/Rakefile +11 -40
- data/lib/rails/generators/ripple/configuration/configuration_generator.rb +0 -13
- data/lib/rails/generators/ripple/configuration/templates/ripple.yml +4 -4
- data/lib/rails/generators/ripple/js/js_generator.rb +0 -13
- data/lib/rails/generators/ripple/js/templates/js/contrib.js +0 -17
- data/lib/rails/generators/ripple/js/templates/js/ripple.js +0 -13
- data/lib/rails/generators/ripple/model/model_generator.rb +0 -14
- data/lib/rails/generators/ripple/model/templates/model.rb +1 -1
- data/lib/rails/generators/ripple/observer/observer_generator.rb +0 -14
- data/lib/rails/generators/ripple/test/test_generator.rb +7 -19
- data/lib/rails/generators/ripple_generator.rb +1 -14
- data/lib/ripple.rb +7 -14
- data/lib/ripple/associations.rb +129 -26
- data/lib/ripple/associations/embedded.rb +1 -15
- data/lib/ripple/associations/instantiators.rb +0 -13
- data/lib/ripple/associations/linked.rb +41 -19
- data/lib/ripple/associations/many.rb +0 -14
- data/lib/ripple/associations/many_embedded_proxy.rb +0 -14
- data/lib/ripple/associations/many_linked_proxy.rb +39 -18
- data/lib/ripple/associations/many_reference_proxy.rb +93 -0
- data/lib/ripple/associations/many_stored_key_proxy.rb +76 -0
- data/lib/ripple/associations/one.rb +1 -15
- data/lib/ripple/associations/one_embedded_proxy.rb +0 -14
- data/lib/ripple/associations/one_key_proxy.rb +58 -0
- data/lib/ripple/associations/one_linked_proxy.rb +4 -14
- data/lib/ripple/associations/one_stored_key_proxy.rb +43 -0
- data/lib/ripple/associations/proxy.rb +8 -14
- data/lib/ripple/attribute_methods.rb +19 -17
- data/lib/ripple/attribute_methods/dirty.rb +19 -15
- data/lib/ripple/attribute_methods/query.rb +0 -14
- data/lib/ripple/attribute_methods/read.rb +0 -14
- data/lib/ripple/attribute_methods/write.rb +0 -14
- data/lib/ripple/callbacks.rb +10 -16
- data/lib/ripple/conflict/basic_resolver.rb +82 -0
- data/lib/ripple/conflict/document_hooks.rb +20 -0
- data/lib/ripple/conflict/resolver.rb +71 -0
- data/lib/ripple/conflict/test_helper.rb +33 -0
- data/lib/ripple/conversion.rb +0 -14
- data/lib/ripple/core_ext.rb +1 -14
- data/lib/ripple/core_ext/casting.rb +19 -19
- data/lib/ripple/core_ext/object.rb +8 -0
- data/lib/ripple/document.rb +21 -16
- data/lib/ripple/document/bucket_access.rb +0 -14
- data/lib/ripple/document/finders.rb +17 -23
- data/lib/ripple/document/key.rb +8 -28
- data/lib/ripple/document/link.rb +30 -0
- data/lib/ripple/document/persistence.rb +12 -20
- data/lib/ripple/embedded_document.rb +10 -15
- data/lib/ripple/embedded_document/around_callbacks.rb +18 -0
- data/lib/ripple/embedded_document/finders.rb +7 -18
- data/lib/ripple/embedded_document/persistence.rb +5 -17
- data/lib/ripple/i18n.rb +0 -14
- data/lib/ripple/inspection.rb +21 -15
- data/lib/ripple/locale/en.yml +9 -13
- data/lib/ripple/nested_attributes.rb +33 -39
- data/lib/ripple/observable.rb +0 -13
- data/lib/ripple/properties.rb +1 -14
- data/lib/ripple/property_type_mismatch.rb +0 -14
- data/lib/ripple/railtie.rb +4 -14
- data/lib/ripple/railties/ripple.rake +86 -0
- data/lib/ripple/serialization.rb +11 -11
- data/lib/ripple/test_server.rb +36 -0
- data/lib/ripple/timestamps.rb +0 -13
- data/lib/ripple/translation.rb +4 -14
- data/lib/ripple/validations.rb +1 -15
- data/lib/ripple/validations/associated_validator.rb +26 -17
- data/lib/ripple/version.rb +3 -0
- data/ripple.gemspec +24 -35
- data/spec/integration/ripple/associations_spec.rb +89 -58
- data/spec/integration/ripple/conflict_resolution_spec.rb +298 -0
- data/spec/integration/ripple/nested_attributes_spec.rb +19 -19
- data/spec/integration/ripple/persistence_spec.rb +15 -34
- data/spec/integration/ripple/search_associations_spec.rb +31 -0
- data/spec/ripple/associations/many_embedded_proxy_spec.rb +23 -36
- data/spec/ripple/associations/many_linked_proxy_spec.rb +133 -45
- data/spec/ripple/associations/many_reference_proxy_spec.rb +170 -0
- data/spec/ripple/associations/many_stored_key_proxy_spec.rb +158 -0
- data/spec/ripple/associations/one_embedded_proxy_spec.rb +24 -37
- data/spec/ripple/associations/one_key_proxy_spec.rb +82 -0
- data/spec/ripple/associations/one_linked_proxy_spec.rb +22 -23
- data/spec/ripple/associations/one_stored_key_proxy_spec.rb +72 -0
- data/spec/ripple/associations/proxy_spec.rb +21 -15
- data/spec/ripple/associations_spec.rb +54 -23
- data/spec/ripple/attribute_methods/dirty_spec.rb +56 -5
- data/spec/ripple/attribute_methods_spec.rb +47 -21
- data/spec/ripple/bucket_access_spec.rb +4 -17
- data/spec/ripple/callbacks_spec.rb +52 -15
- data/spec/ripple/conflict/resolver_spec.rb +42 -0
- data/spec/ripple/conversion_spec.rb +2 -15
- data/spec/ripple/core_ext_spec.rb +12 -15
- data/spec/ripple/document/link_spec.rb +67 -0
- data/spec/ripple/document_spec.rb +34 -19
- data/spec/ripple/embedded_document/finders_spec.rb +12 -19
- data/spec/ripple/embedded_document/persistence_spec.rb +20 -26
- data/spec/ripple/embedded_document_spec.rb +44 -34
- data/spec/ripple/finders_spec.rb +58 -29
- data/spec/ripple/inspection_spec.rb +40 -37
- data/spec/ripple/key_spec.rb +5 -17
- data/spec/ripple/observable_spec.rb +3 -16
- data/spec/ripple/persistence_spec.rb +134 -18
- data/spec/ripple/properties_spec.rb +21 -15
- data/spec/ripple/ripple_spec.rb +1 -14
- data/spec/ripple/serialization_spec.rb +16 -17
- data/spec/ripple/timestamps_spec.rb +73 -52
- data/spec/ripple/validations/associated_validator_spec.rb +69 -25
- data/spec/ripple/validations_spec.rb +3 -16
- data/spec/spec_helper.rb +17 -18
- data/spec/support/associations.rb +1 -1
- data/spec/support/associations/proxies.rb +0 -13
- data/spec/support/integration_setup.rb +11 -0
- data/spec/support/mocks.rb +0 -13
- data/spec/support/models.rb +33 -2
- data/spec/support/models/address.rb +1 -16
- data/spec/support/models/box.rb +7 -14
- data/spec/support/models/car.rb +27 -1
- data/spec/support/models/cardboard_box.rb +0 -14
- data/spec/support/models/clock.rb +6 -15
- data/spec/support/models/clock_observer.rb +0 -14
- data/spec/support/models/credit_card.rb +5 -0
- data/spec/support/models/customer.rb +0 -14
- data/spec/support/models/email.rb +0 -14
- data/spec/support/models/family.rb +1 -13
- data/spec/support/models/favorite.rb +0 -14
- data/spec/support/models/invoice.rb +0 -14
- data/spec/support/models/late_invoice.rb +0 -14
- data/spec/support/models/nested.rb +12 -0
- data/spec/support/models/ninja.rb +7 -0
- data/spec/support/models/note.rb +0 -14
- data/spec/support/models/page.rb +1 -15
- data/spec/support/models/paid_invoice.rb +0 -14
- data/spec/support/models/post.rb +12 -0
- data/spec/support/models/profile.rb +7 -0
- data/spec/support/models/subscription.rb +26 -0
- data/spec/support/models/tasks.rb +0 -18
- data/spec/support/models/team.rb +11 -0
- data/spec/support/models/transactions.rb +17 -0
- data/spec/support/models/tree.rb +2 -16
- data/spec/support/models/user.rb +14 -16
- data/spec/support/models/widget.rb +8 -14
- data/spec/support/search.rb +14 -0
- data/spec/support/test_server.rb +22 -12
- data/spec/support/test_server.yml.example +14 -2
- metadata +223 -59
- data/lib/rails/generators/ripple/test/templates/test_server.rb +0 -46
- data/spec/support/models/driver.rb +0 -5
- data/spec/support/models/engine.rb +0 -4
- data/spec/support/models/passenger.rb +0 -5
- data/spec/support/models/seat.rb +0 -4
- data/spec/support/models/wheel.rb +0 -5
@@ -1,17 +1,3 @@
|
|
1
|
-
# Copyright 2010 Sean Cribbs, Sonian Inc., and Basho Technologies, Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
1
|
require 'ripple/associations/proxy'
|
16
2
|
require 'ripple/validations/associated_validator'
|
17
3
|
|
@@ -25,7 +11,7 @@ module Ripple
|
|
25
11
|
end
|
26
12
|
|
27
13
|
protected
|
28
|
-
|
14
|
+
|
29
15
|
def lazy_load_validates_associated
|
30
16
|
return if @owner.class.validators_on(@reflection.name).any? {|v| Ripple::Validations::AssociatedValidator === v}
|
31
17
|
@owner.class.validates @reflection.name, :associated => true
|
@@ -1,16 +1,3 @@
|
|
1
|
-
# Copyright 2010 Sean Cribbs, Sonian Inc., and Basho Technologies, Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
1
|
require 'ripple/associations'
|
15
2
|
|
16
3
|
module Ripple
|
@@ -1,18 +1,5 @@
|
|
1
|
-
# Copyright 2010 Sean Cribbs, Sonian Inc., and Basho Technologies, Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
1
|
require 'ripple/associations'
|
2
|
+
require 'set'
|
16
3
|
|
17
4
|
module Ripple
|
18
5
|
module Associations
|
@@ -21,22 +8,57 @@ module Ripple
|
|
21
8
|
@reflection.verify_type!(value, @owner)
|
22
9
|
@owner.robject.links -= links
|
23
10
|
Array(value).compact.each do |doc|
|
24
|
-
|
25
|
-
@owner.robject.links << doc.robject.to_link(@reflection.link_tag)
|
11
|
+
@owner.robject.links << doc.to_link(@reflection.link_tag)
|
26
12
|
end
|
27
13
|
loaded
|
14
|
+
@keys = nil
|
28
15
|
@target = value
|
29
16
|
end
|
30
17
|
|
18
|
+
def replace_links(value)
|
19
|
+
@owner.robject.links -= links
|
20
|
+
Array(value).each do |link|
|
21
|
+
@owner.robject.links << link
|
22
|
+
end
|
23
|
+
reset
|
24
|
+
end
|
25
|
+
|
26
|
+
def keys
|
27
|
+
@keys ||= Set.new(links.map { |l| l.key })
|
28
|
+
end
|
29
|
+
|
30
|
+
def reset
|
31
|
+
super
|
32
|
+
@keys = nil
|
33
|
+
end
|
34
|
+
|
35
|
+
def include?(document)
|
36
|
+
return false unless document.respond_to?(:robject)
|
37
|
+
|
38
|
+
# TODO: when we allow polymorphic assocations, this will have to change
|
39
|
+
# since @reflection.bucket_name will be '_' in that case.
|
40
|
+
return false unless document.robject.bucket.name == @reflection.bucket_name
|
41
|
+
keys.include?(document.key)
|
42
|
+
end
|
43
|
+
|
31
44
|
protected
|
32
45
|
def links
|
33
46
|
@owner.robject.links.select(&@reflection.link_filter)
|
34
47
|
end
|
35
48
|
|
36
49
|
def robjects
|
37
|
-
|
38
|
-
|
39
|
-
|
50
|
+
walk_result = begin
|
51
|
+
@owner.robject.walk(*Array(@reflection.link_spec)).first || []
|
52
|
+
rescue
|
53
|
+
[]
|
54
|
+
end
|
55
|
+
|
56
|
+
# We can get more robject results that we have links when there is conflict,
|
57
|
+
# since link-walking returns the robjects for the union of all sibling links.
|
58
|
+
# Here, we filter out robjects that should not be included.
|
59
|
+
walk_result.select do |robject|
|
60
|
+
links.include?(robject.to_link(@reflection.link_tag))
|
61
|
+
end
|
40
62
|
end
|
41
63
|
end
|
42
64
|
end
|
@@ -1,17 +1,3 @@
|
|
1
|
-
# Copyright 2010 Sean Cribbs, Sonian Inc., and Basho Technologies, Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
1
|
require 'ripple/associations'
|
16
2
|
|
17
3
|
module Ripple
|
@@ -1,17 +1,3 @@
|
|
1
|
-
# Copyright 2010 Sean Cribbs, Sonian Inc., and Basho Technologies, Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
1
|
require 'ripple/associations/proxy'
|
16
2
|
require 'ripple/associations/many'
|
17
3
|
require 'ripple/associations/embedded'
|
@@ -1,17 +1,3 @@
|
|
1
|
-
# Copyright 2010 Sean Cribbs, Sonian Inc., and Basho Technologies, Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
1
|
require 'ripple/associations/proxy'
|
16
2
|
require 'ripple/associations/many'
|
17
3
|
require 'ripple/associations/linked'
|
@@ -22,10 +8,22 @@ module Ripple
|
|
22
8
|
include Many
|
23
9
|
include Linked
|
24
10
|
|
11
|
+
def count
|
12
|
+
# avoid having to load all documents by using our keys set instead
|
13
|
+
keys.size
|
14
|
+
end
|
15
|
+
|
25
16
|
def <<(value)
|
26
|
-
|
27
|
-
|
28
|
-
|
17
|
+
if loaded?
|
18
|
+
new_target = @target.concat(Array(value))
|
19
|
+
replace new_target
|
20
|
+
else
|
21
|
+
@reflection.verify_type!([value], @owner)
|
22
|
+
@owner.robject.links << value.to_link(@reflection.link_tag)
|
23
|
+
appended_documents << value
|
24
|
+
@keys = nil
|
25
|
+
end
|
26
|
+
|
29
27
|
self
|
30
28
|
end
|
31
29
|
|
@@ -36,9 +34,32 @@ module Ripple
|
|
36
34
|
self
|
37
35
|
end
|
38
36
|
|
37
|
+
def reset
|
38
|
+
@appended_documents = nil
|
39
|
+
super
|
40
|
+
end
|
41
|
+
|
42
|
+
def loaded_documents
|
43
|
+
(super + appended_documents).uniq
|
44
|
+
end
|
45
|
+
|
39
46
|
protected
|
47
|
+
|
40
48
|
def find_target
|
41
|
-
|
49
|
+
robjs = robjects
|
50
|
+
|
51
|
+
robjs.delete_if do |robj|
|
52
|
+
appended_documents.any? do |doc|
|
53
|
+
doc.key == robj.key &&
|
54
|
+
doc.class.bucket_name == robj.bucket.name
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
appended_documents + robjs.map {|robj| klass.send(:instantiate, robj) }
|
59
|
+
end
|
60
|
+
|
61
|
+
def appended_documents
|
62
|
+
@appended_documents ||= []
|
42
63
|
end
|
43
64
|
end
|
44
65
|
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'ripple/associations/proxy'
|
2
|
+
require 'ripple/associations/many'
|
3
|
+
|
4
|
+
require 'set'
|
5
|
+
|
6
|
+
module Ripple
|
7
|
+
module Associations
|
8
|
+
class ManyReferenceProxy < Proxy
|
9
|
+
include Many
|
10
|
+
|
11
|
+
def <<(value)
|
12
|
+
@reflection.verify_type!([value], @owner)
|
13
|
+
|
14
|
+
assign_key(value)
|
15
|
+
load_target
|
16
|
+
@target << value
|
17
|
+
|
18
|
+
self
|
19
|
+
end
|
20
|
+
|
21
|
+
def replace(value)
|
22
|
+
@reflection.verify_type!(value, @owner)
|
23
|
+
delete_all
|
24
|
+
Array(value).compact.each do |doc|
|
25
|
+
assign_key(doc)
|
26
|
+
end
|
27
|
+
loaded
|
28
|
+
@keys = nil
|
29
|
+
@target = Set.new(value)
|
30
|
+
end
|
31
|
+
|
32
|
+
def delete_all
|
33
|
+
load_target
|
34
|
+
@target.each do |e|
|
35
|
+
delete(e)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def delete(value)
|
40
|
+
load_target
|
41
|
+
assign_key(value, nil)
|
42
|
+
@target.delete(value)
|
43
|
+
end
|
44
|
+
|
45
|
+
def target
|
46
|
+
@target.to_a
|
47
|
+
end
|
48
|
+
|
49
|
+
def keys
|
50
|
+
@keys ||= Ripple.client.search(klass.bucket_name, "#{key_name}: #{@owner.key}")["response"]["docs"].inject(Set.new) do |set, search_document|
|
51
|
+
set << search_document["id"]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def reset
|
56
|
+
@keys = nil
|
57
|
+
super
|
58
|
+
end
|
59
|
+
|
60
|
+
def include?(document)
|
61
|
+
return false unless document.class.respond_to?(:bucket_name)
|
62
|
+
|
63
|
+
return false unless document.class.bucket_name == @reflection.bucket_name
|
64
|
+
keys.include?(document.key)
|
65
|
+
end
|
66
|
+
|
67
|
+
def count
|
68
|
+
if loaded?
|
69
|
+
@target.count
|
70
|
+
else
|
71
|
+
keys.count
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
protected
|
76
|
+
def find_target
|
77
|
+
Set.new(klass.find(keys.to_a))
|
78
|
+
end
|
79
|
+
|
80
|
+
def key_name
|
81
|
+
"#{@owner.class.name.underscore}_key"
|
82
|
+
end
|
83
|
+
|
84
|
+
def assign_key(target, key=@owner.key)
|
85
|
+
if target.new_record?
|
86
|
+
target.send("#{key_name}=", key)
|
87
|
+
else
|
88
|
+
target.update_attribute(key_name, key)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'ripple/associations/proxy'
|
2
|
+
require 'ripple/associations/many'
|
3
|
+
|
4
|
+
module Ripple
|
5
|
+
module Associations
|
6
|
+
class ManyStoredKeyProxy < Proxy
|
7
|
+
include Many
|
8
|
+
|
9
|
+
def count
|
10
|
+
keys.size
|
11
|
+
end
|
12
|
+
|
13
|
+
def <<(value)
|
14
|
+
@reflection.verify_type!([value], @owner)
|
15
|
+
|
16
|
+
raise "Unable to append if the document isn't first saved." if value.new_record?
|
17
|
+
load_target
|
18
|
+
@target << value
|
19
|
+
keys << value.key
|
20
|
+
|
21
|
+
self
|
22
|
+
end
|
23
|
+
|
24
|
+
def replace(value)
|
25
|
+
@reflection.verify_type!(value, @owner)
|
26
|
+
|
27
|
+
reset_owner_keys
|
28
|
+
value.each { |doc| self << doc }
|
29
|
+
@target = value
|
30
|
+
loaded
|
31
|
+
end
|
32
|
+
|
33
|
+
def delete(value)
|
34
|
+
keys.delete(value.key)
|
35
|
+
self
|
36
|
+
end
|
37
|
+
|
38
|
+
def keys
|
39
|
+
if @owner.send(keys_name).nil?
|
40
|
+
reset_owner_keys
|
41
|
+
end
|
42
|
+
|
43
|
+
@owner.send(keys_name)
|
44
|
+
end
|
45
|
+
|
46
|
+
def reset
|
47
|
+
super
|
48
|
+
self.owner_keys = @owner.robject.data ? @owner.robject.data[keys_name] : []
|
49
|
+
end
|
50
|
+
|
51
|
+
def include?(document)
|
52
|
+
return false unless document.respond_to?(:robject)
|
53
|
+
return false unless document.robject.bucket.name == @reflection.bucket_name
|
54
|
+
keys.include?(document.key)
|
55
|
+
end
|
56
|
+
|
57
|
+
def reset_owner_keys
|
58
|
+
self.owner_keys = []
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
protected
|
63
|
+
def find_target
|
64
|
+
klass.find(keys.to_a)
|
65
|
+
end
|
66
|
+
|
67
|
+
def keys_name
|
68
|
+
"#{@reflection.name.to_s.singularize}_keys"
|
69
|
+
end
|
70
|
+
|
71
|
+
def owner_keys=(new_keys)
|
72
|
+
@owner.send("#{keys_name}=", @owner.class.properties[keys_name].type.new(new_keys))
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -1,17 +1,3 @@
|
|
1
|
-
# Copyright 2010 Sean Cribbs, Sonian Inc., and Basho Technologies, Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
1
|
require 'ripple/associations/instantiators'
|
16
2
|
|
17
3
|
module Ripple
|
@@ -22,7 +8,7 @@ module Ripple
|
|
22
8
|
def to_a
|
23
9
|
[self]
|
24
10
|
end
|
25
|
-
|
11
|
+
|
26
12
|
protected
|
27
13
|
def instantiate_target(instantiator, attrs={})
|
28
14
|
@target = klass.send(instantiator, attrs)
|
@@ -1,17 +1,3 @@
|
|
1
|
-
# Copyright 2010 Sean Cribbs, Sonian Inc., and Basho Technologies, Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
1
|
require 'ripple/associations/proxy'
|
16
2
|
require 'ripple/associations/one'
|
17
3
|
require 'ripple/associations/embedded'
|