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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8aef98c4504dee98e437999a2fbfc3fb087363a
|
4
|
+
data.tar.gz: 737920031f79621eff0163e2547a93a86cc2829b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 619873a35e03b3c0ed16ae23e9f28ff97abcbe2525a581beaa91889c508c77ad74565d043d10f619ffedf44f7c7828a6e1a65374f01ca849b8c0d7b8c61cbbd2
|
7
|
+
data.tar.gz: f3c817c0b0a99a41063969946f6420fce4847379f5d6bce11e431996a8ff6978846bfe2347b67db0a22d82ff0882fb53ab4bc215711dc627f94d2cb74d981c75
|
@@ -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).
|
data/spec/passive_record_spec.rb
CHANGED
@@ -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\")")
|