bullet_train-has_uuid 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/concerns/has_uuid.rb +21 -0
- data/lib/bullet_train/has_uuid/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbc4cba4c7e84ece751dac2ee38ce86ca4438df9ef24921d257ded95b3d80f54
|
4
|
+
data.tar.gz: 045a2a820e74da6986b176fa297747b4597106948853bf88cc8d14d7769e7db0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52520c5e6de74da7cacb26561576ef2584d6c1acbe5b259bce83f89c1b2a23d29108eeb59bec2db08ed0fed8c6abb511dffe8dbb7ac69eac5913705d6fe49875
|
7
|
+
data.tar.gz: 339325f15245bd1cb6435d972015fb0598b1a53c13528e164b233c2fff72f2b397e6168e79e79e52dcfb38e2093d890dd6e5e60bbfab656a5aae96c5ac371f32
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module HasUuid
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
# define relationships.
|
5
|
+
included do
|
6
|
+
after_initialize do
|
7
|
+
self.uuid ||= SecureRandom.hex
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# define class methods.
|
12
|
+
module ClassMethods
|
13
|
+
end
|
14
|
+
|
15
|
+
# define object methods.
|
16
|
+
def short_uuid
|
17
|
+
self.uuid.first(7)
|
18
|
+
rescue
|
19
|
+
"nil"
|
20
|
+
end
|
21
|
+
end
|