model_id 0.0.1 → 0.0.2
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/README.md +9 -2
- data/lib/model_id/base.rb +4 -0
- data/lib/model_id/version.rb +1 -1
- data/spec/model_id_spec.rb +7 -0
- 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: 1bf11cfa0e155744b639dd5eaf6b218bfaa8555f
|
4
|
+
data.tar.gz: 3e0ece3f6216eff0f4dd0bda1b70bb2492c5734f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3f29ffbff48feeb467c3dcd9a659780dab9520f335aa849a66269ac2ef340f365f1e02e1a742283a3917064c7fb132ef25a7954ddea786540072a3d40544dda
|
7
|
+
data.tar.gz: 19046a6b0979206d1781b5e46f740fbd1a5c9d03699429accd9edf4a1d50e5490a5135fe8c315977ce0f89f21a0b7348d761cda31a3ecacdd3e5835e10414896
|
data/README.md
CHANGED
@@ -28,10 +28,17 @@ Now your model has #model_id:
|
|
28
28
|
|
29
29
|
User.new.model_id
|
30
30
|
|
31
|
-
And you
|
31
|
+
And you can find instances by id:
|
32
32
|
|
33
33
|
user = User.new
|
34
|
-
User.find_by_id(user.model_id)
|
34
|
+
User.find_by_id(user.model_id) # => user
|
35
|
+
|
36
|
+
After you don't need this instance anymore you can delete it from the index by #delete_model:
|
37
|
+
|
38
|
+
user = User.new
|
39
|
+
User.find_by_id(user.model_id) # => user
|
40
|
+
user.delete_model
|
41
|
+
User.find_by_id(user.model_id) # => nil
|
35
42
|
|
36
43
|
## Notes
|
37
44
|
|
data/lib/model_id/base.rb
CHANGED
data/lib/model_id/version.rb
CHANGED
data/spec/model_id_spec.rb
CHANGED
@@ -44,4 +44,11 @@ describe ModelId::Base do
|
|
44
44
|
expect(@class_with_id.find_by_id(first_instance.model_id)).to eql(first_instance)
|
45
45
|
expect(@class_with_id.find_by_id(second_instance.model_id)).to eql(second_instance)
|
46
46
|
end
|
47
|
+
|
48
|
+
it 'should delete model from index' do
|
49
|
+
instance = @class_with_id.new
|
50
|
+
expect(@class_with_id.find_by_id(instance.model_id)).to eql(instance)
|
51
|
+
instance.delete_model
|
52
|
+
expect(@class_with_id.find_by_id(instance.model_id)).to be_nil
|
53
|
+
end
|
47
54
|
end
|