active_node 2.3.3 → 2.3.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 068907cb909d3802f5a52c3b9ec3645bd5ab3246
|
4
|
+
data.tar.gz: 8fd0b5d063bcf6226b3f307804e89f843b3084bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b949f9fb780fe090b81c6d99c5683fa271c26f01fdb1f521e3de177492b05c35dccf3fb8b5afd96754f8004908c920d2c7f4f3472054b137f76071de208fad6
|
7
|
+
data.tar.gz: 6de7ce32dbb5a33c8e11c2b07dfcb0219757aca660f09b99b81e0a6ce8d7e6e83560600fd919252edc876a70e28529506b5af79030a4d8142700fa8dfcfea4c4
|
@@ -47,12 +47,17 @@ module ActiveNode
|
|
47
47
|
|
48
48
|
# Implements the writer method, e.g. foo.items= for Foo.has_many :items
|
49
49
|
def writer(records)
|
50
|
+
records = load_ids(records)
|
50
51
|
validate_type(records)
|
51
52
|
@dirty = true
|
52
53
|
@rel_target = nil
|
53
54
|
@target = records
|
54
55
|
end
|
55
56
|
|
57
|
+
def load_ids(records)
|
58
|
+
records.map {|r| ActiveNode::Base === r ? r : reflection.klass.find(r)}
|
59
|
+
end
|
60
|
+
|
56
61
|
def validate_type(records)
|
57
62
|
unless records.all? { |r| r.is_a?(reflection.klass) }
|
58
63
|
raise ArgumentError, "#{reflection.name} can only accept object(s) of class #{reflection.klass}"
|
@@ -64,7 +69,7 @@ module ActiveNode
|
|
64
69
|
# Implements the ids writer method, e.g. foo.item_ids= for Foo.has_many :items
|
65
70
|
def ids_writer(ids)
|
66
71
|
@rel_target = nil
|
67
|
-
super_writer klass.find(ids.reject(&:blank?)
|
72
|
+
super_writer klass.find(ids.reject(&:blank?))
|
68
73
|
end
|
69
74
|
|
70
75
|
def reader(*args)
|
data/lib/active_node/version.rb
CHANGED
@@ -28,6 +28,18 @@ describe ActiveNode::Associations do
|
|
28
28
|
expect(Client.find(client.id).users).to eq([user])
|
29
29
|
end
|
30
30
|
|
31
|
+
it "can send id to association" do
|
32
|
+
user = NeoUser.create!(name: 'Heinrich')
|
33
|
+
client = Client.create!(name: 'a', users: [user.id])
|
34
|
+
expect(client.users.to_a).to eq([user])
|
35
|
+
end
|
36
|
+
|
37
|
+
it "can send node to association_id" do
|
38
|
+
user = NeoUser.create!(name: 'Heinrich')
|
39
|
+
client = Client.create!(name: 'a', user_ids: [user])
|
40
|
+
expect(client.users.to_a).to eq([user])
|
41
|
+
end
|
42
|
+
|
31
43
|
it "can remove associated objects" do
|
32
44
|
user = NeoUser.new(name: 'Heinrich')
|
33
45
|
user.save
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_node
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Heinrich Klobuczek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_attr
|