active_node 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/active_node/persistence.rb +8 -3
- data/lib/active_node/version.rb +1 -1
- data/spec/functional/persistence_spec.rb +12 -0
- data/spec/models/person.rb +1 -0
- metadata +2 -2
@@ -2,6 +2,10 @@ module ActiveNode
|
|
2
2
|
module Persistence
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
|
+
included do
|
6
|
+
attribute :id
|
7
|
+
end
|
8
|
+
|
5
9
|
module ClassMethods
|
6
10
|
def find ids
|
7
11
|
ids.is_a?(Enumerable) ? ids.map { |id| find(id) } : new_instance(Neography::Node.load(ids))
|
@@ -40,13 +44,14 @@ module ActiveNode
|
|
40
44
|
def id
|
41
45
|
neo_id && neo_id.to_i
|
42
46
|
end
|
43
|
-
|
44
47
|
alias :to_param :id
|
45
48
|
alias :persisted? :id
|
49
|
+
|
46
50
|
alias :[] :send
|
47
51
|
|
48
|
-
def initialize
|
49
|
-
|
52
|
+
def initialize object={}
|
53
|
+
hash=object
|
54
|
+
@node, hash = object, object.send(:table) if object.is_a? Neography::Node
|
50
55
|
super hash
|
51
56
|
end
|
52
57
|
|
data/lib/active_node/version.rb
CHANGED
@@ -26,4 +26,16 @@ describe ActiveNode::Persistence do
|
|
26
26
|
Person.all.count.should == 2
|
27
27
|
end
|
28
28
|
end
|
29
|
+
|
30
|
+
describe "#create!" do
|
31
|
+
it "should persist attributes" do
|
32
|
+
Person.create!(name: 'abc').name.should == 'abc'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#attributes" do
|
37
|
+
it "should include id" do
|
38
|
+
Person.create!(name: 'abc').attributes['id'].should_not be_nil
|
39
|
+
end
|
40
|
+
end
|
29
41
|
end
|
data/spec/models/person.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_node
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: active_attr
|