passive_record 0.2.0 → 0.2.1

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: 1108d5a60097b6842bd5c72184c6fac8a653c75a
4
- data.tar.gz: 7f567c9a374209c45aa17a62000df702a1c2b98e
3
+ metadata.gz: 9b53a2a2b1407842b155927cd33dcd17edf6122e
4
+ data.tar.gz: 683d3db18dda5ed63fe3c38eaa04245869384589
5
5
  SHA512:
6
- metadata.gz: 4b2d37f1524aeb2d3fbb33dc98cd6306ba12c043808b26b39b3df711db85d8bb78ebb16fba96f6f6fd9af64994a7b3cb242b7b59cfb1097461947ba81e057ce7
7
- data.tar.gz: 6141a330284cc2bf5d8d0b8dec749fc63e7b24441983b0ed5f98c3bf3bcbf61273fd1595a84845a5c549d3fbc106acd8256cec77e7d8274851629a1882e6806c
6
+ metadata.gz: a84823bc45ca818c2b9d4321e866a27d0fccf96e9fd577127c733da3cdc1f0417af3e213fc4601097c4e60faa4005e7dbb5743554d4b5b5e370f8a6411d99c01
7
+ data.tar.gz: b908e5b58a80c708bd015365807e5947643d4c2090b5dae48d070bdae439777c934bb9a3b876cbc102b290663889742a5dcc0f5a777135011eac05050ddcceb8
@@ -29,7 +29,7 @@ module PassiveRecord
29
29
  end
30
30
 
31
31
  def parent_class_name
32
- association.parent_class.name.underscore
32
+ association.parent_class.name.split('::').last.underscore
33
33
  end
34
34
 
35
35
  def child_class
@@ -1,4 +1,4 @@
1
1
  module PassiveRecord
2
2
  # passive_record version
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
@@ -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
- class Dog < Model
19
- attr_reader :sound
20
- belongs_to :child
21
- after_create {@sound = 'bark'}
22
- end
23
-
24
- class Toy < Model
25
- belongs_to :child
26
- attr_reader :kind
27
- after_create {@kind = %w[ stuffed_animal blocks cards ].sample}
28
- end
29
-
30
- class Child < Model
31
- has_one :toy
32
- has_many :dogs
33
- belongs_to :parent
34
-
35
- attr_reader :name
36
- after_create :give_name
37
-
38
- def give_name; @name = "Alice" end
39
- end
40
-
41
- class Parent < Model
42
- has_many :children
43
- has_many :dogs, :through => :children
44
- has_many :toys, :through => :children
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: passive_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Weissman