passive_record 0.3.7 → 0.3.8

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: fc8b97dbc45fa4523ccd68e4ab1fcd5e8cb7a195
4
- data.tar.gz: 6213a7c2a314d2b6231d56708cd189fc4cc33d82
3
+ metadata.gz: f8aef98c4504dee98e437999a2fbfc3fb087363a
4
+ data.tar.gz: 737920031f79621eff0163e2547a93a86cc2829b
5
5
  SHA512:
6
- metadata.gz: 9ef69a79461f22a4d8f633996b7783d29eca541f448638087e57015f2513df998c24ca5208bf6cb9b46f254e0c582b27b6edc60cfdf2568830193969868f030a
7
- data.tar.gz: 29506381b9effa9c5e2864e2ddb48137a6b3d716c39aa754ea3e8d16071e83b28331f353012728315bda8f1793bfba12d0365d2e2925bf95509e4cff8a156b58
6
+ metadata.gz: 619873a35e03b3c0ed16ae23e9f28ff97abcbe2525a581beaa91889c508c77ad74565d043d10f619ffedf44f7c7828a6e1a65374f01ca849b8c0d7b8c61cbbd2
7
+ data.tar.gz: f3c817c0b0a99a41063969946f6420fce4847379f5d6bce11e431996a8ff6978846bfe2347b67db0a22d82ff0882fb53ab4bc215711dc627f94d2cb74d981c75
@@ -72,6 +72,10 @@ module PassiveRecord
72
72
  instance
73
73
  end
74
74
 
75
+ def destroy(id)
76
+ @instances.delete(id)
77
+ end
78
+
75
79
  def destroy_all
76
80
  @instances = {}
77
81
  end
@@ -16,6 +16,10 @@ module PassiveRecord
16
16
  self
17
17
  end
18
18
 
19
+ def destroy
20
+ self.class.destroy(self.id)
21
+ end
22
+
19
23
  # from http://stackoverflow.com/a/8417341/90042
20
24
  def to_h
21
25
  Hash[
@@ -97,7 +101,7 @@ module PassiveRecord
97
101
  when "#{target_name}="
98
102
  if args.first.is_a?(Array)
99
103
  if matching_relation.is_a?(Associations::HasManyThroughRelation)
100
- intermediary = matching_relation.intermediary_relation
104
+ intermediary = matching_relation.intermediary_relation
101
105
  args.first.each do |child|
102
106
  intermediary.
103
107
  where((target_name.singularize + "_id").to_sym => child.id).
@@ -1,4 +1,4 @@
1
1
  module PassiveRecord
2
2
  # passive_record version
3
- VERSION = "0.3.7"
3
+ VERSION = "0.3.8"
4
4
  end
@@ -17,7 +17,7 @@ describe PassiveRecord do
17
17
  end
18
18
 
19
19
  describe "passive record models" do
20
- before { PassiveRecord.drop_all }
20
+ before(:each) { PassiveRecord.drop_all }
21
21
 
22
22
  context "with a simple model including PR" do
23
23
  let!(:model) { SimpleModel.create(foo: value) }
@@ -35,6 +35,15 @@ describe "passive record models" do
35
35
  end
36
36
  end
37
37
 
38
+ describe "#destroy" do
39
+ it 'should remove the entity and freeze it' do
40
+ doomed = SimpleModel.create
41
+ expect(SimpleModel.find(doomed.id)).to eq(doomed)
42
+ doomed.destroy
43
+ expect(SimpleModel.find(doomed.id)).to eq(nil)
44
+ end
45
+ end
46
+
38
47
  describe "#inspect" do
39
48
  it 'should report attribute details' do
40
49
  expect(model.inspect).to eq("SimpleModel (id: #{model.id.inspect}, foo: \"foo_value\")")
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.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Weissman