couchbase-jruby-model 0.1.1-java → 0.1.2-java
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.
- checksums.yaml +4 -4
- data/lib/couchbase/model.rb +1 -1
- data/lib/couchbase/model/version.rb +1 -1
- data/test/test_model.rb +16 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df785ec9171f5f4ec0ba4e594097301d7eba54de
|
4
|
+
data.tar.gz: d029ce0fd61ad35cdbea0b6f9f6b88c6ebfd752d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad3527b5db0327bb5320e1e1d3e5ffe4ea980a89adccc937ed893b405e3cc513c1ccee02022bd6b2dfa5df30cebf7bbc8fe1b1fb389b776370541e1484706514
|
7
|
+
data.tar.gz: c1180f1e1a60061921dd6c256993a75fdde68224876eefba770bfec45f80beb12fa81be67ec967aadc96e6a1b80370d467672eb882ffed852b415e53ce1da9d9
|
data/lib/couchbase/model.rb
CHANGED
@@ -393,7 +393,7 @@ module Couchbase
|
|
393
393
|
def self.belongs_to(name, options = {})
|
394
394
|
ref = "#{name}_id"
|
395
395
|
attribute(ref)
|
396
|
-
assoc = name.to_s.camelize.constantize
|
396
|
+
assoc = (options[:class_name] || name).to_s.camelize.constantize
|
397
397
|
define_method(name) do
|
398
398
|
assoc.find(self.send(ref))
|
399
399
|
end
|
data/test/test_model.rb
CHANGED
@@ -41,6 +41,11 @@ class Beer < Couchbase::Model
|
|
41
41
|
belongs_to :brewery
|
42
42
|
end
|
43
43
|
|
44
|
+
class Wine < Couchbase::Model
|
45
|
+
attribute :name
|
46
|
+
belongs_to :winery, :class_name => :Brewery
|
47
|
+
end
|
48
|
+
|
44
49
|
class Attachment < Couchbase::Model
|
45
50
|
defaults :format => :plain
|
46
51
|
end
|
@@ -59,7 +64,7 @@ class TestModel < MiniTest::Unit::TestCase
|
|
59
64
|
def setup
|
60
65
|
@mock = start_mock
|
61
66
|
bucket = Couchbase.connect(:hostname => @mock.host, :port => @mock.port)
|
62
|
-
[Post, ValidPost, Brewery, Beer, Attachment].each do |model|
|
67
|
+
[Post, ValidPost, Brewery, Beer, Attachment, Wine].each do |model|
|
63
68
|
model.bucket = bucket
|
64
69
|
end
|
65
70
|
end
|
@@ -217,6 +222,16 @@ class TestModel < MiniTest::Unit::TestCase
|
|
217
222
|
end
|
218
223
|
end
|
219
224
|
|
225
|
+
def test_belongs_to_with_class_name_assoc
|
226
|
+
brewery = Brewery.create(:name => "R Wines")
|
227
|
+
assert_includes Wine.attributes.keys, :winery_id
|
228
|
+
wine = Wine.create(:name => "Classy", :winery_id => brewery.id)
|
229
|
+
assert_respond_to wine, :winery
|
230
|
+
assoc = wine.winery
|
231
|
+
assert_instance_of Brewery, assoc
|
232
|
+
assert_equal "R Wines", assoc.name
|
233
|
+
end
|
234
|
+
|
220
235
|
def test_fails_to_delete_model_without_id
|
221
236
|
post = Post.new(:title => 'Hello')
|
222
237
|
refute post.id
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: couchbase-jruby-model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Couchbase
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: couchbase-jruby-client
|