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.
@@ -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 hash={}
49
- @node, hash = hash, hash.send(:table) if hash.is_a? Neography::Node
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
 
@@ -1,3 +1,3 @@
1
1
  module ActiveNode
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -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
@@ -1,4 +1,5 @@
1
1
  class Person < ActiveNode::Base
2
+ attribute :name, type: String
2
3
  has_many :people
3
4
  has_many :children, class_name: "Person"
4
5
  has_one :father, type: :child, direction: :incoming, class_name: "Person"
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.3
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-09-26 00:00:00.000000000 Z
12
+ date: 2013-10-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: active_attr