passive_record 0.2.0 → 0.2.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 +4 -4
- data/lib/passive_record/associations/has_one.rb +1 -1
- data/lib/passive_record/version.rb +1 -1
- data/spec/passive_record_spec.rb +1 -1
- data/spec/spec_helper.rb +30 -27
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b53a2a2b1407842b155927cd33dcd17edf6122e
|
4
|
+
data.tar.gz: 683d3db18dda5ed63fe3c38eaa04245869384589
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a84823bc45ca818c2b9d4321e866a27d0fccf96e9fd577127c733da3cdc1f0417af3e213fc4601097c4e60faa4005e7dbb5743554d4b5b5e370f8a6411d99c01
|
7
|
+
data.tar.gz: b908e5b58a80c708bd015365807e5947643d4c2090b5dae48d070bdae439777c934bb9a3b876cbc102b290663889742a5dcc0f5a777135011eac05050ddcceb8
|
data/spec/passive_record_spec.rb
CHANGED
@@ -29,7 +29,7 @@ describe "passive record models" do
|
|
29
29
|
|
30
30
|
it 'should report relations' do
|
31
31
|
dog = Dog.create
|
32
|
-
expect(dog.inspect).to eq("Dog (id: #{dog.id.inspect}, created_at: #{dog.created_at}, sound: \"bark\", child_id: nil)")
|
32
|
+
expect(dog.inspect).to eq("Family::Dog (id: #{dog.id.inspect}, created_at: #{dog.created_at}, sound: \"bark\", child_id: nil)")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
data/spec/spec_helper.rb
CHANGED
@@ -15,34 +15,37 @@ class SimpleModel < Struct.new(:foo)
|
|
15
15
|
include PassiveRecord
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
18
|
+
module Family
|
19
|
+
class Dog < Model
|
20
|
+
attr_reader :sound
|
21
|
+
belongs_to :child
|
22
|
+
after_create {@sound = 'bark'}
|
23
|
+
end
|
24
|
+
|
25
|
+
class Toy < Model
|
26
|
+
belongs_to :child
|
27
|
+
attr_reader :kind
|
28
|
+
after_create {@kind = %w[ stuffed_animal blocks cards ].sample}
|
29
|
+
end
|
30
|
+
|
31
|
+
class Child < Model
|
32
|
+
has_one :toy
|
33
|
+
has_many :dogs
|
34
|
+
belongs_to :parent
|
35
|
+
|
36
|
+
attr_reader :name
|
37
|
+
after_create :give_name
|
38
|
+
|
39
|
+
def give_name; @name = "Alice" end
|
40
|
+
end
|
41
|
+
|
42
|
+
class Parent < Model
|
43
|
+
has_many :children
|
44
|
+
has_many :dogs, :through => :children
|
45
|
+
has_many :toys, :through => :children
|
46
|
+
end
|
45
47
|
end
|
48
|
+
include Family
|
46
49
|
|
47
50
|
###
|
48
51
|
|