universalid 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/lib/universal_id/version.rb +1 -1
- data/lib/universal_id.rb +11 -11
- 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: '00684769ef0a97127ef4342a3b61ef58bba2f85a7fb1ddfe55118186f7c93662'
|
4
|
+
data.tar.gz: 4f871efbddfb4b580d60d556cd4ca12c8135f5331dad58bac19d3152b5066282
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a34c1492a6b4fc39babca2e246d5055fc2212104285e43a9ec4b460441d71886e76f77ebab3afb94b4f03cc03d3615975e2e348bafcbc473d7f67632cc36de6
|
7
|
+
data.tar.gz: 124d30882de946bf8abf6b801b44bb471c0df1d0b262f0424cb449707a01c2635b1f97892c0972bcff12411437a16b7f4fcfb0698162feafb2a3a231ce69b719
|
data/README.md
CHANGED
@@ -1016,7 +1016,11 @@ This is especially useful in scenarios where the data format evolves over time,
|
|
1016
1016
|
# | encoding options (whatever was passed to URI::UID.build or {})
|
1017
1017
|
# | |
|
1018
1018
|
uid = URI::UID.build(campaign) do |record, options|
|
1019
|
+
# NOTE: this feature is compatible with other tools like kiba, amoeba, etc.
|
1020
|
+
# that can be leveraged to generate the data to be encoded
|
1021
|
+
|
1019
1022
|
data = { id: record.id, demo: true }
|
1023
|
+
|
1020
1024
|
URI::UID.encode data, options.merge(include: %w[id demo]) # block returns the encoded payload
|
1021
1025
|
end
|
1022
1026
|
```
|
@@ -1029,6 +1033,9 @@ This is especially useful in scenarios where the data format evolves over time,
|
|
1029
1033
|
# the decoded payload from above | |
|
1030
1034
|
# | | |
|
1031
1035
|
decoded = URI::UID.parse(uid.to_s).decode do |data, klass, timestamp|
|
1036
|
+
# NOTE: this feature is compatible with other tools like kiba, amoeba, etc.
|
1037
|
+
# that can be leveraged to translate the decoded data into the correct format
|
1038
|
+
|
1032
1039
|
record = klass.find_by(id: data[:id])
|
1033
1040
|
record.instance_variable_set(:@demo, data[:demo])
|
1034
1041
|
|
data/lib/universal_id/version.rb
CHANGED
data/lib/universal_id.rb
CHANGED
@@ -5,17 +5,6 @@ require "forwardable"
|
|
5
5
|
require "ostruct"
|
6
6
|
require "uri"
|
7
7
|
|
8
|
-
require_relative "universal_id/version"
|
9
|
-
require_relative "universal_id/refinements"
|
10
|
-
require_relative "universal_id/settings"
|
11
|
-
require_relative "universal_id/encoder"
|
12
|
-
require_relative "uri/uid"
|
13
|
-
require_relative "universal_id/prepacker"
|
14
|
-
require_relative "universal_id/prepack_options"
|
15
|
-
require_relative "universal_id/message_pack_factory"
|
16
|
-
|
17
|
-
UniversalID::Settings.instance # initialize settings
|
18
|
-
|
19
8
|
module UniversalID
|
20
9
|
module Contrib; end
|
21
10
|
|
@@ -27,3 +16,14 @@ module UniversalID
|
|
27
16
|
end
|
28
17
|
end
|
29
18
|
end
|
19
|
+
|
20
|
+
require_relative "universal_id/version"
|
21
|
+
require_relative "universal_id/refinements"
|
22
|
+
require_relative "universal_id/settings"
|
23
|
+
require_relative "universal_id/encoder"
|
24
|
+
require_relative "uri/uid"
|
25
|
+
require_relative "universal_id/prepacker"
|
26
|
+
require_relative "universal_id/prepack_options"
|
27
|
+
require_relative "universal_id/message_pack_factory"
|
28
|
+
|
29
|
+
UniversalID::Settings.instance # initialize settings
|