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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 633b4897fb41d52b43a38c447293075952130222
4
- data.tar.gz: c939c9511b4c5a01f1161f37eb23adbe0dac2ae9
3
+ metadata.gz: 009873db2285d63fc20017f441525c2356dec8b9
4
+ data.tar.gz: 59aab9d43e21d1fb9376ddde89feecfdfe9c82f9
5
5
  SHA512:
6
- metadata.gz: de208cc8bc0ca9a337440cec472ac500536461859b8b716c515f834ce9225350dcf54a9dc1744a8e9b0e021441f77258269d2ed11a17e6a273f5f027e3641107
7
- data.tar.gz: 50e23dff5cf8d65cc6e42084b34e74766cfd879a14abe31731ff2b960d8963b646465b5aca47cfbc01883ed6da171c5fcde6deda6df729b33878191f21a6f26e
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
@@ -1,3 +1,3 @@
1
1
  module ActiveNode
2
- VERSION = "0.1"
2
+ VERSION = "0.2"
3
3
  end
@@ -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("START n0=node(0),nx=node(*) MATCH n0-[r0?]-(),nx-[rx?]-() WHERE nx <> n0 DELETE r0,rx,nx")
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.1'
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: 2013-11-09 00:00:00.000000000 Z
11
+ date: 2014-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_attr