active_node 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_node/persistence.rb +5 -1
- data/lib/active_node/version.rb +1 -1
- data/spec/functional/persistence_spec.rb +10 -0
- data/spec/spec_helper.rb +1 -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: 009873db2285d63fc20017f441525c2356dec8b9
|
4
|
+
data.tar.gz: 59aab9d43e21d1fb9376ddde89feecfdfe9c82f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 506c0696d7db079e83d2e36ddf00be5dc3e0e1088c037755f6d3ad0205faf50a89a6def731093dbf66df5dc3ddfa13b853eb5e4bfe748c2f99550465e445942b
|
7
|
+
data.tar.gz: 5594c6ce98652b3549369628bd6fb33e3f7eab56199e69e7a4c23d6b0bab9f7a421db842c1fe313593f97352653c7cab8ea08298fc2db1be63c83d6ba3f255b8
|
@@ -60,7 +60,7 @@ module ActiveNode
|
|
60
60
|
|
61
61
|
def initialize object={}
|
62
62
|
hash=object
|
63
|
-
@node, hash = object, object.send(:table) if object.is_a? Neography::Node
|
63
|
+
@node, hash = object, declared_attributes_only(object.send(:table)) if object.is_a? Neography::Node
|
64
64
|
super hash
|
65
65
|
end
|
66
66
|
|
@@ -93,6 +93,10 @@ module ActiveNode
|
|
93
93
|
end
|
94
94
|
|
95
95
|
private
|
96
|
+
def declared_attributes_only hash
|
97
|
+
hash.try(:select) { |k, _| self.class.attribute_names.include? k.to_s }
|
98
|
+
end
|
99
|
+
|
96
100
|
def related(direction, types, klass)
|
97
101
|
node && self.class.filterClass(node.send(direction, types), klass)
|
98
102
|
end
|
data/lib/active_node/version.rb
CHANGED
@@ -7,6 +7,16 @@ describe ActiveNode::Persistence do
|
|
7
7
|
NeoUser.all.map(&:name).should == ['Heinrich']
|
8
8
|
end
|
9
9
|
|
10
|
+
it "should save object with non attribute properties with a name of a relationship" do
|
11
|
+
child = Person.create!
|
12
|
+
person = Person.create! children: [child]
|
13
|
+
person.node[:children] = "Bob"
|
14
|
+
person = Person.find person.id
|
15
|
+
person.save
|
16
|
+
person.node[:children].should == "Bob"
|
17
|
+
person.children.should == [child]
|
18
|
+
end
|
19
|
+
|
10
20
|
it 'should destroy node' do
|
11
21
|
user = NeoUser.create!(name: 'abc')
|
12
22
|
NeoUser.all.count.should == 1
|
data/spec/spec_helper.rb
CHANGED
@@ -36,7 +36,7 @@ RSpec.configure do |c|
|
|
36
36
|
#end
|
37
37
|
c.before(:each) do
|
38
38
|
@neo=Neography::Rest.new
|
39
|
-
@neo.execute_query("
|
39
|
+
@neo.execute_query("MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE n,r")
|
40
40
|
@neo.set_node_auto_index_status(true)
|
41
41
|
@neo.add_node_auto_index_property('type')
|
42
42
|
end
|
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: '0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Heinrich Klobuczek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_attr
|