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: 54ea207f36a379b3c584d9c37fe2c045da8e8a01
4
- data.tar.gz: f484ee30f29b4ae820470f1dd1bc3aa583bf8aaa
3
+ metadata.gz: 068907cb909d3802f5a52c3b9ec3645bd5ab3246
4
+ data.tar.gz: 8fd0b5d063bcf6226b3f307804e89f843b3084bf
5
5
  SHA512:
6
- metadata.gz: 82318d09eb4b0c34346514fc2c956d6e9f622e2d588941f85506b9e2d490788be7d1c0453e006c7ce1cd32f638911b47d1b53bbe113285f641bcced0b992bfe1
7
- data.tar.gz: 25acaa945884d9ed45d2ff00e21c03f6dc7a2d062c891445e7b22c15dd140e6564d8b9e2a973dbc3f5af7881894fbde4e2fbaee762bdd8db119da605878fd2c8
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?).map!(&:to_i))
72
+ super_writer klass.find(ids.reject(&:blank?))
68
73
  end
69
74
 
70
75
  def reader(*args)
@@ -1,3 +1,3 @@
1
1
  module ActiveNode
2
- VERSION = "2.3.3"
2
+ VERSION = "2.3.4"
3
3
  end
@@ -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
@@ -62,6 +62,7 @@ describe ActiveNode::Persistence do
62
62
  it 'should not record timestamp if not specified' do
63
63
  expect(Client.create!(name: 'abc').respond_to?(:created_at)).to be_falsey
64
64
  end
65
+
65
66
  end
66
67
 
67
68
  describe "#destroyed?" do
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.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-04-18 00:00:00.000000000 Z
11
+ date: 2015-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_attr