active_node 0.0.9 → 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e32d1933debb95430cfc3d820944ea3479d7988f
4
- data.tar.gz: 375d91720da215173862384110956dda27a75aca
3
+ metadata.gz: 633b4897fb41d52b43a38c447293075952130222
4
+ data.tar.gz: c939c9511b4c5a01f1161f37eb23adbe0dac2ae9
5
5
  SHA512:
6
- metadata.gz: c3752f3a8db9de2115f3162501d389eeab00c4cdc4ef2cf54fbcc9c450de1206d5c5e2e27acfdceb185f5f6d886e2fdd91dcc64867d28dbb5cf4e9510e54bc6f
7
- data.tar.gz: 2bbe7644d054796e1994efd9567f2fe0818826fceaa927995fde422a66ba5aeed1dd49ad7fa64712bf97381328057325173013e076937e5b3adafb73e92f1c4b
6
+ metadata.gz: de208cc8bc0ca9a337440cec472ac500536461859b8b716c515f834ce9225350dcf54a9dc1744a8e9b0e021441f77258269d2ed11a17e6a273f5f027e3641107
7
+ data.tar.gz: 50e23dff5cf8d65cc6e42084b34e74766cfd879a14abe31731ff2b960d8963b646465b5aca47cfbc01883ed6da171c5fcde6deda6df729b33878191f21a6f26e
@@ -37,7 +37,7 @@ module ActiveNode
37
37
  end
38
38
 
39
39
  def filterClass(nodes, klass)
40
- wrap(nodes, klass).select { |model| model.instance_of? klass }
40
+ wrap(nodes, klass).select { |model| klass.nil? || model.instance_of?(klass) }
41
41
  end
42
42
 
43
43
  private
@@ -1,3 +1,3 @@
1
1
  module ActiveNode
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1"
3
3
  end
@@ -33,7 +33,7 @@ describe ActiveNode::Persistence do
33
33
  person = Person.find(person.id)
34
34
  person.created_at.should_not be_nil
35
35
  person.updated_at.should_not be_nil
36
- allow(Time).to receive(:now) {now + 1.second}
36
+ allow(Time).to receive(:now) { now + 1.second }
37
37
  person.name = 'abc'
38
38
  person.save
39
39
  (person.created_at < person.updated_at).should be_true
@@ -64,4 +64,13 @@ describe ActiveNode::Persistence do
64
64
  Person.create!(name: 'abc').attributes['id'].should_not be_nil
65
65
  end
66
66
  end
67
+
68
+ describe "#incoming" do
69
+ it "can retrieve heterogenous models" do
70
+ a = Address.create!
71
+ p=Person.create!(name: 'abc', address: a)
72
+ c=Client.create!(name: 'client', address: a)
73
+ a.incoming(:address).should include(p, c)
74
+ end
75
+ end
67
76
  end
@@ -0,0 +1,2 @@
1
+ class Address < ActiveNode::Base
2
+ end
@@ -2,6 +2,7 @@ class Client < ActiveNode::Base
2
2
  attribute :name, type: String
3
3
 
4
4
  has_many :users, direction: :incoming, class_name: 'NeoUser'
5
+ has_one :address
5
6
 
6
7
  validates :name, presence: true
7
8
  end
@@ -7,4 +7,5 @@ class Person < ActiveNode::Base
7
7
  has_many :children, class_name: "Person"
8
8
  #has_many :sons, class_name: "Person"
9
9
  has_one :father, type: :child, direction: :incoming, class_name: "Person"
10
+ has_one :address
10
11
  end
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.9
4
+ version: '0.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Heinrich Klobuczek
@@ -159,6 +159,7 @@ files:
159
159
  - spec/functional/associations_spec.rb
160
160
  - spec/functional/persistence_spec.rb
161
161
  - spec/functional/validations_spec.rb
162
+ - spec/models/address.rb
162
163
  - spec/models/client.rb
163
164
  - spec/models/neo_user.rb
164
165
  - spec/models/person.rb
@@ -190,6 +191,7 @@ test_files:
190
191
  - spec/functional/associations_spec.rb
191
192
  - spec/functional/persistence_spec.rb
192
193
  - spec/functional/validations_spec.rb
194
+ - spec/models/address.rb
193
195
  - spec/models/client.rb
194
196
  - spec/models/neo_user.rb
195
197
  - spec/models/person.rb