loggable_activity 0.1.53 → 0.1.55

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -0
  3. data/CHANGELOG.md +6 -0
  4. data/GETTING-STARTED.md +5 -12
  5. data/README.md +2 -0
  6. data/docs/LoggableActivity/Activity.html +108 -139
  7. data/docs/LoggableActivity/Configuration.html +3 -3
  8. data/docs/LoggableActivity/Encryption.html +7 -4
  9. data/docs/LoggableActivity/EncryptionKey.html +4 -2
  10. data/docs/LoggableActivity/Hooks.html +37 -37
  11. data/docs/LoggableActivity/Payload.html +32 -6
  12. data/docs/LoggableActivity/PayloadsBuilder.html +14 -11
  13. data/docs/LoggableActivity/UpdatePayloadsBuilder.html +29 -28
  14. data/docs/LoggableActivity.html +3 -1
  15. data/docs/created.rid +10 -10
  16. data/docs/js/search_index.js +1 -1
  17. data/docs/js/search_index.js.gz +0 -0
  18. data/docs/table_of_contents.html +14 -4
  19. data/help/loggable_activity_help.txt +19 -0
  20. data/lib/generators/loggable_activity/.DS_Store +0 -0
  21. data/lib/generators/loggable_activity/install_generator.rb +94 -6
  22. data/lib/generators/loggable_activity/install_templates_generator.rb +61 -0
  23. data/lib/generators/loggable_activity/templates/.DS_Store +0 -0
  24. data/lib/generators/loggable_activity/templates/binary_ids/create_loggable_activities.rb +31 -0
  25. data/lib/generators/loggable_activity/templates/create_loggable_activities.rb +17 -0
  26. data/lib/generators/loggable_activity/templates/helpers/loggable_activity_helper.rb +2 -2
  27. data/lib/generators/loggable_activity/templates/loggable_activity_helper.rb +14 -5
  28. data/lib/loggable_activity/activity.rb +56 -107
  29. data/lib/loggable_activity/configuration.rb +1 -0
  30. data/lib/loggable_activity/encryption.rb +6 -2
  31. data/lib/loggable_activity/encryption_key.rb +2 -0
  32. data/lib/loggable_activity/hooks.rb +20 -1
  33. data/lib/loggable_activity/payload.rb +7 -0
  34. data/lib/loggable_activity/payloads_builder.rb +6 -3
  35. data/lib/loggable_activity/update_payloads_builder.rb +17 -7
  36. data/lib/loggable_activity/version.rb +3 -1
  37. data/lib/loggable_activity.rb +0 -1
  38. metadata +6 -6
  39. data/lib/generators/loggable_activity/templates/create_loggable_encryption_keys.rb +0 -11
  40. data/lib/generators/loggable_activity/templates/create_loggable_payloads.rb +0 -15
  41. /data/lib/generators/loggable_activity/templates/config/{loggable_activity.yml → loggable_activity.yaml} +0 -0
  42. /data/lib/generators/loggable_activity/templates/{loggable_activity.en.yml → loggable_activity.en.yaml} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 780e8614a8e5b1c9e97a70a9cb432e8a277d3617dd845fc38b7c41a235b282a9
4
- data.tar.gz: fea7bb11d9abcbeeb0423381c4a462df03c07e4ea4487d8e958e9ffe3479ff1f
3
+ metadata.gz: 2e2ab2f4d7ec08a5f53176ae3e3289b8470c5cc39013a1bc48e06c3b596f11ee
4
+ data.tar.gz: 3c5037f59fc9e408fd693afbd3208f530b52cb4f3791b91f8dfad603a66e2513
5
5
  SHA512:
6
- metadata.gz: 262803990c60f23a9edcd0484105e0ecac141350d8d4710c5344db7dbe5836587b3959fea74be0890f9abb0e4b0c3a5324f8725d02e3fdd493cbdb3dbcbb53c2
7
- data.tar.gz: 1ee1f8eb1850e8150665d9fc65b075c2eac86d7054f6921dee10fd35329e0643e3aa101d416b60278a5695eb8e1b4ef64e3a0ff76e0a13611f31868c31d7d0e2
6
+ metadata.gz: 017f1f1418adb7acd44ed3af4cd08ccdcc396dc9d61c63b2b584c994b46018923832155a1ae64361a8d75c5414257591ff174e33696c356c844c241063343c14
7
+ data.tar.gz: 2da5d2b4981ad8470f6ed75b2710c6e75f36d19dafb99496cc0e49f1e7c2a0f008b94d234780c693e6eb841437ffa6933f7abd133526a6c9eec56b8e75fa1259
data/.rubocop.yml CHANGED
@@ -38,3 +38,5 @@ Metrics/AbcSize:
38
38
  Exclude:
39
39
  - lib/loggable_activity/encryption.rb
40
40
  - lib/loggable_activity/update_payloads_builder.rb
41
+ - lib/generators/loggable_activity/templates/binary_ids/create_loggable_activities.rb
42
+ - lib/generators/loggable_activity/templates/create_loggable_activities.rb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [0.1.54] - 2024-02-24
2
+ - Support for BinaryID's
3
+ - Updated README.md
4
+ - Quick start guid in terminal after installations
5
+ - Support for slim
6
+
1
7
  ## [0.1.53] - 2024-02-22
2
8
  - Generator for presentation layer
3
9
  - GETTING-STARTED.md guide
data/GETTING-STARTED.md CHANGED
@@ -26,17 +26,9 @@ This will install the following files
26
26
  - config/loggable_activity.yml
27
27
  - config/locales/loggable_activity.en.yml
28
28
  - db/migrate/xxxxxxxxxxxxxx_create_loggable_activities
29
- - db/migrate/xxxxxxxxxxxxxx_create_loggable_payloads
30
- - db/migrate/xxxxxxxxxxxxxx_create_loggable_encryption_keys
31
29
 
32
- Then we have to run
33
- ```
34
- $ bundle install
35
- ```
36
-
37
- ## Add hoks to models you want to be logged
38
- Include hooks to the model we want to log.
39
30
 
31
+ ## Add hoks to models to be logged
40
32
  ```
41
33
  class User < ApplicationRecord
42
34
  include LoggableActivity::Hooks
@@ -67,8 +59,9 @@ This file defines:
67
59
  *Here is an example of content for the config/loggable_activity.yaml file*
68
60
  ```
69
61
  Demo::Club:
70
- record_display_name: name
62
+ record_display_name: email
71
63
  loggable_attrs:
64
+ - email
72
65
  - name
73
66
  auto_log:
74
67
  - create
@@ -123,7 +116,7 @@ $ rails g loggable_activity:install_templates
123
116
  ```
124
117
  or for the slim template language. (don't run both)
125
118
  ```
126
- $ rails g loggable_activity:install_templates --template=erb
119
+ $ rails g loggable_activity:install_templates --template=slim
127
120
  ```
128
121
  Now you got the `loggable_activity_helper.rb' installed.<br/>
129
122
  You can use the `render_activity` method from your view like this.
@@ -162,4 +155,4 @@ end
162
155
  If you can download and play around with a demo app
163
156
  - 1 Down the demo project from [demo project on github](https://github.com/maxgronlund/LoggableActivityDemoApp)
164
157
  - 2 Update the Gemfile in the demo project so it points to your localhost.
165
- - 3 you can now build and test you version of the gem `$ gem build loggable_activity.gemspec`
158
+ - 3 you can now build and test you version of the gem `$ gem build loggable_activity.gemspec`
data/README.md CHANGED
@@ -4,6 +4,8 @@ Secure protect data and log how it is handled
4
4
  - Protect and secure the privacy of data stored in Activity Logs
5
5
  - Prepare for General Data Protection Regulation (GDPR) compliance.
6
6
  - Handles activities that involves more than one table in the DB.
7
+ - Encrypt data stored in the activity log
8
+ - Support binary_ids
7
9
 
8
10
  ### Important!
9
11
  This project is under development and not ready for production. There might be breaking changes, so please consult the CHANGELOG.md
@@ -80,6 +80,7 @@
80
80
  <li ><a href="#method-i-attrs">#attrs</a>
81
81
  <li ><a href="#method-i-must_have_at_least_one_payload">#must_have_at_least_one_payload</a>
82
82
  <li ><a href="#method-i-ordered_payloads">#ordered_payloads</a>
83
+ <li ><a href="#method-i-path">#path</a>
83
84
  <li ><a href="#method-i-previous_associations_attrs">#previous_associations_attrs</a>
84
85
  <li ><a href="#method-i-primary_payload">#primary_payload</a>
85
86
  <li ><a href="#method-i-primary_payload_attrs">#primary_payload_attrs</a>
@@ -130,7 +131,7 @@
130
131
  <p>Returns a list of activities for a given actor.</p>
131
132
 
132
133
  <div class="method-source-code" id="activities_for_actor-source">
133
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 214</span>
134
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 155</span>
134
135
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">activities_for_actor</span>(<span class="ruby-identifier">actor</span>, <span class="ruby-identifier">limit</span> = <span class="ruby-value">20</span>, <span class="ruby-identifier">params</span> = { <span class="ruby-value">offset:</span> <span class="ruby-value">0</span> })
135
136
  <span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">Activity</span>.<span class="ruby-identifier">latest</span>(<span class="ruby-identifier">limit</span>, <span class="ruby-identifier">params</span>).<span class="ruby-identifier">where</span>(<span class="ruby-value">actor:</span>)
136
137
  <span class="ruby-keyword">end</span></pre>
@@ -153,7 +154,7 @@
153
154
  <p>Returns the last activity.</p>
154
155
 
155
156
  <div class="method-source-code" id="last-source">
156
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 230</span>
157
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 171</span>
157
158
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">last</span>(<span class="ruby-identifier">limit</span> = <span class="ruby-value">1</span>)
158
159
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">latest</span>(<span class="ruby-value">1</span>).<span class="ruby-identifier">first</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">limit</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
159
160
 
@@ -178,7 +179,7 @@
178
179
  <p>Returns a list of activities ordered by creation date.</p>
179
180
 
180
181
  <div class="method-source-code" id="latest-source">
181
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 219</span>
182
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 160</span>
182
183
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">latest</span>(<span class="ruby-identifier">limit</span> = <span class="ruby-value">20</span>, <span class="ruby-identifier">params</span> = { <span class="ruby-value">offset:</span> <span class="ruby-value">0</span> })
183
184
  <span class="ruby-identifier">offset</span> = <span class="ruby-identifier">params</span>[<span class="ruby-value">:offset</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0</span>
184
185
  <span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">Activity</span>
@@ -224,7 +225,7 @@
224
225
  </pre>
225
226
 
226
227
  <div class="method-source-code" id="actor_display_name-source">
227
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 207</span>
228
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 148</span>
228
229
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">actor_display_name</span>
229
230
  <span class="ruby-keyword">return</span> <span class="ruby-constant">I18n</span>.<span class="ruby-identifier">t</span>(<span class="ruby-string">&#39;loggable.activity.deleted&#39;</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">encrypted_actor_display_name</span>.<span class="ruby-identifier">nil?</span>
230
231
 
@@ -246,63 +247,40 @@
246
247
  </div>
247
248
 
248
249
  <div class="method-description">
249
- <p>Returns a list of attributes of the activity includig the indliced relations. The included relations are devined in the ‘config/loggable_activity.yaml file. The attributes are packed in a way that they can be used to display the activity in the UI.</p>
250
+ <p>Returns an array of hashes, each representing an activity’s attributes and its associated relations. The structure and relations to include are specified in ‘config/loggable_activity.yaml’. This format is designed for UI display purposes.</p>
250
251
 
251
- <p>Example:</p>
252
+ <p>Each hash in the array contains:</p>
253
+ <ul><li>
254
+ <p>:record_type: The class name of the record.</p>
255
+ </li><li>
256
+ <p>:payload_type: A descriptor of the payload’s role (e.g., ‘primary_payload’ or ‘current_association’).</p>
257
+ </li><li>
258
+ <p>:attrs: A hash of the record’s attributes.</p>
259
+ </li></ul>
260
+
261
+ <p>Example usage:</p>
252
262
 
253
263
  <pre class="ruby"><span class="ruby-ivar">@activity</span>.<span class="ruby-identifier">attrs</span>
254
264
  </pre>
255
265
 
256
- <p>Returns:</p>
266
+ <p>Sample return value:</p>
257
267
 
258
- <pre class="ruby"> [
259
- {
260
- <span class="ruby-value">record_class:</span> <span class="ruby-string">&quot;User&quot;</span>,
261
- <span class="ruby-value">payload_type:</span> <span class="ruby-string">&quot;primary_payload&quot;</span>,
262
- <span class="ruby-value">attrs:</span> {
263
- <span class="ruby-string">&quot;first_name&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;David&quot;</span>,
264
- <span class="ruby-string">&quot;last_name&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;Bowie&quot;</span>,
265
- <span class="ruby-string">&quot;age&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;69&quot;</span>,
266
- <span class="ruby-string">&quot;email&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;david@example.com&quot;</span>,
267
- <span class="ruby-string">&quot;user_type&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;Patient&quot;</span>
268
- }
269
- },
270
- {
271
- <span class="ruby-value">record_class:</span> <span class="ruby-string">&quot;Demo::UserProfile&quot;</span>,
272
- <span class="ruby-value">payload_type:</span> <span class="ruby-string">&quot;current_association&quot;</span>,
273
- <span class="ruby-value">attrs:</span> {
274
- <span class="ruby-string">&quot;sex&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;Male&quot;</span>,
275
- <span class="ruby-string">&quot;religion&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;Agnostic&quot;</span>
276
- }
277
- },
278
- {
279
- <span class="ruby-value">record_class:</span> <span class="ruby-string">&quot;Demo::Address&quot;</span>,
280
- <span class="ruby-value">payload_type:</span> <span class="ruby-string">&quot;current_association&quot;</span>,
281
- <span class="ruby-value">attrs:</span> {
282
- <span class="ruby-string">&quot;street&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;Eiffel Tower&quot;</span>,
283
- <span class="ruby-string">&quot;city&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;Paris&quot;</span>,
284
- <span class="ruby-string">&quot;country&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;France&quot;</span>,
285
- <span class="ruby-string">&quot;postal_code&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;75007&quot;</span>
286
- }
287
- },
288
- {
289
- <span class="ruby-value">record_class:</span> <span class="ruby-string">&quot;Demo::Club&quot;</span>,
290
- <span class="ruby-value">payload_type:</span> <span class="ruby-string">&quot;current_association&quot;</span>,
291
- <span class="ruby-value">attrs:</span> {
292
- <span class="ruby-string">&quot;name&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;Mystic Fusion Lounge&quot;</span>
293
- }
294
- }
295
- ]
296
- </pre>
268
+ <pre>[
269
+ { record_type: MODEL_NAME, payload_type: &quot;primary_payload&quot;, attrs: { &quot;KEY&quot; =&gt; &quot;VALUE&quot;, ... } },
270
+ { record_type: MODEL_NAME, payload_type: &quot;current_association&quot;, attrs: { &quot;KEY&quot; =&gt; &quot;VALUE&quot;, ... } },
271
+ ...
272
+ ]</pre>
297
273
 
298
274
  <div class="method-source-code" id="attrs-source">
299
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 68</span>
275
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 37</span>
300
276
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">attrs</span>
301
277
  <span class="ruby-identifier">ordered_payloads</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">payload</span><span class="ruby-operator">|</span>
302
278
  {
303
- <span class="ruby-value">record_class:</span> <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">record_type</span>,
279
+ <span class="ruby-value">record_type:</span> <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">record_type</span>,
280
+ <span class="ruby-value">record_id:</span> <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">record_id</span>,
304
281
  <span class="ruby-value">payload_type:</span> <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">payload_type</span>,
305
- <span class="ruby-value">attrs:</span> <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">attrs</span>
282
+ <span class="ruby-value">attrs:</span> <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">attrs</span>,
283
+ <span class="ruby-value">path:</span> <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">payload_route</span>
306
284
  }
307
285
  <span class="ruby-keyword">end</span>
308
286
  <span class="ruby-keyword">end</span></pre>
@@ -310,6 +288,39 @@
310
288
  </div>
311
289
 
312
290
 
291
+ </div>
292
+
293
+ <div id="method-i-path" class="method-detail ">
294
+ <div class="method-header">
295
+ <div class="method-heading">
296
+ <span class="method-name">path</span><span
297
+ class="method-args">()</span>
298
+ <span class="method-click-advice">click to toggle source</span>
299
+ </div>
300
+ </div>
301
+
302
+ <div class="method-description">
303
+ <p>Returns the path for the activity.</p>
304
+
305
+ <p>Example:</p>
306
+
307
+ <pre class="ruby"><span class="ruby-ivar">@activity</span>.<span class="ruby-identifier">path</span>
308
+ </pre>
309
+
310
+ <p>Returns:</p>
311
+
312
+ <pre class="ruby"><span class="ruby-string">&quot;/path/to/activity&quot;</span>
313
+ </pre>
314
+
315
+ <div class="method-source-code" id="path-source">
316
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 135</span>
317
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">path</span>
318
+ <span class="ruby-identifier">primary_payload</span>&amp;.<span class="ruby-identifier">route</span>
319
+ <span class="ruby-keyword">end</span></pre>
320
+ </div>
321
+ </div>
322
+
323
+
313
324
  </div>
314
325
 
315
326
  <div id="method-i-primary_payload_attrs" class="method-detail ">
@@ -331,17 +342,10 @@
331
342
 
332
343
  <p>Returns:</p>
333
344
 
334
- <pre class="ruby">{
335
- <span class="ruby-string">&quot;first_name&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;David&quot;</span>,
336
- <span class="ruby-string">&quot;last_name&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;Bowie&quot;</span>,
337
- <span class="ruby-string">&quot;age&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;69&quot;</span>,
338
- <span class="ruby-string">&quot;email&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;david@example.com&quot;</span>,
339
- <span class="ruby-string">&quot;user_type&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;Patient&quot;</span>
340
- }
341
- </pre>
345
+ <pre>{ &quot;KEY_A&quot; =&gt; &quot;VALUE_A&quot;, &quot;KEY_B&quot; =&gt; &quot;VALUE_B&quot;, ... }</pre>
342
346
 
343
347
  <div class="method-source-code" id="primary_payload_attrs-source">
344
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 154</span>
348
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 88</span>
345
349
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">primary_payload_attrs</span>
346
350
  <span class="ruby-identifier">primary_payload</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">primary_payload</span>.<span class="ruby-identifier">attrs</span> <span class="ruby-operator">:</span> {}
347
351
  <span class="ruby-keyword">end</span></pre>
@@ -374,7 +378,7 @@
374
378
  </pre>
375
379
 
376
380
  <div class="method-source-code" id="record_display_name-source">
377
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 192</span>
381
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 120</span>
378
382
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">record_display_name</span>
379
383
  <span class="ruby-keyword">return</span> <span class="ruby-constant">I18n</span>.<span class="ruby-identifier">t</span>(<span class="ruby-string">&#39;loggable.activity.deleted&#39;</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">encrypted_record_display_name</span>.<span class="ruby-identifier">nil?</span>
380
384
 
@@ -405,24 +409,17 @@
405
409
 
406
410
  <p>Returns:</p>
407
411
 
408
- <pre class="ruby">[
412
+ <pre>[
409
413
  {
410
- <span class="ruby-value">record_class:</span> <span class="ruby-string">&quot;Demo::Address&quot;</span>,
411
- <span class="ruby-comment"># Current association payload type</span>
412
- <span class="ruby-value">payload_type:</span> <span class="ruby-string">&quot;current_association&quot;</span>,
413
- <span class="ruby-comment"># Current attributes for Demo::Address</span>
414
- <span class="ruby-value">attrs:</span> {
415
- <span class="ruby-string">&quot;street&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;The Palace of Versailles&quot;</span>,
416
- <span class="ruby-string">&quot;city&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;Versailles&quot;</span>,
417
- <span class="ruby-string">&quot;country&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;France&quot;</span>,
418
- <span class="ruby-string">&quot;postal_code&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;78000&quot;</span>
419
- }
414
+ record_type: CLASS.NAME,
415
+ record_id: INTEGER,
416
+ payload_type: ENUM
417
+ attrs: { &quot;KEY_A&quot; =&gt; &quot;VALUE_A&quot;, &quot;KEY_B&quot; =&gt; &quot;VALUE_B&quot;, ... }
420
418
  }
421
- ]
422
- </pre>
419
+ ]</pre>
423
420
 
424
421
  <div class="method-source-code" id="relations_attrs-source">
425
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 179</span>
422
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 107</span>
426
423
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">relations_attrs</span>
427
424
  <span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">filter</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span>[<span class="ruby-value">:payload_type</span>] <span class="ruby-operator">==</span> <span class="ruby-string">&#39;current_association&#39;</span> }
428
425
  <span class="ruby-keyword">end</span></pre>
@@ -442,66 +439,38 @@
442
439
  </div>
443
440
 
444
441
  <div class="method-description">
445
- <p>Returns the attributes of an upddate activity.</p>
442
+ <p>Returns a hash describing the attributes of an update activity, including updated attributes for a record and any updated related attributes.</p>
446
443
 
447
444
  <p>Example:</p>
448
445
 
449
446
  <pre class="ruby"><span class="ruby-ivar">@activity</span>.<span class="ruby-identifier">update_activity_attrs</span>
450
447
  </pre>
451
448
 
452
- <p>Returns:</p>
449
+ <p>The return value is structured as follows:</p>
450
+ <ul><li>
451
+ <p>:update_attrs contains the attributes of the record being updated, detailing changes from previous to new values.</p>
452
+ </li><li>
453
+ <p>:updated_relations_attrs is an array of hashes, each representing an updated related record. Each hash details the previous and current attributes of the relation.</p>
454
+ </li></ul>
455
+
456
+ <p>Example Return Structure:</p>
453
457
 
454
- <pre class="ruby">{
455
- <span class="ruby-comment"># Update attributes for Demo::Club</span>
456
- <span class="ruby-value">update_attrs:</span> {
457
- <span class="ruby-value">record_class:</span> <span class="ruby-string">&quot;Demo::Club&quot;</span>,
458
- <span class="ruby-value">attrs:</span> [
459
- {
460
- <span class="ruby-string">&quot;name&quot;</span> <span class="ruby-operator">=&gt;</span> {
461
- <span class="ruby-comment"># Previous name</span>
462
- <span class="ruby-value">from:</span> <span class="ruby-string">&quot;Electric Oasis Club&quot;</span>,
463
- <span class="ruby-comment"># New name</span>
464
- <span class="ruby-value">to:</span> <span class="ruby-string">&quot;Electric Oasis Club nr 5&quot;</span>
465
- }
466
- }
467
- ]
458
+ <pre>{
459
+ update_attrs: {
460
+ record_class: &quot;CLASS.NAME&quot;,
461
+ attrs: [{ &quot;KEY&quot; =&gt; { from: &quot;OLD_VALUE&quot;, to: &quot;NEW_VALUE&quot; } }]
468
462
  },
469
- <span class="ruby-comment"># Updated relations attributes</span>
470
- <span class="ruby-value">updated_relations_attrs:</span> [
463
+ updated_relations_attrs: [
471
464
  {
472
- <span class="ruby-value">record_class:</span> <span class="ruby-string">&quot;Demo::Address&quot;</span>,
473
- <span class="ruby-value">previous_attrs:</span> {
474
- <span class="ruby-comment"># Record class</span>
475
- <span class="ruby-value">record_class:</span> <span class="ruby-string">&quot;Demo::Address&quot;</span>,
476
- <span class="ruby-comment"># Previous association payload type</span>
477
- <span class="ruby-value">payload_type:</span> <span class="ruby-string">&quot;previous_association&quot;</span>,
478
- <span class="ruby-comment"># Previous attributes for Demo::Address</span>
479
- <span class="ruby-value">attrs:</span> {
480
- <span class="ruby-string">&quot;street&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;Ice Hotel, Marknadsvägen 63&quot;</span>,
481
- <span class="ruby-string">&quot;city&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;Jukkasjärvi&quot;</span>,
482
- <span class="ruby-string">&quot;country&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;Sweden&quot;</span>,
483
- <span class="ruby-string">&quot;postal_code&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;981 91&quot;</span>
484
- }
485
- },
486
- <span class="ruby-value">current_attrs:</span> {
487
- <span class="ruby-value">record_class:</span> <span class="ruby-string">&quot;Demo::Address&quot;</span>,
488
- <span class="ruby-comment"># Current association payload type</span>
489
- <span class="ruby-value">payload_type:</span> <span class="ruby-string">&quot;current_association&quot;</span>,
490
- <span class="ruby-comment"># Current attributes for Demo::Address</span>
491
- <span class="ruby-value">attrs:</span> {
492
- <span class="ruby-string">&quot;street&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;The Palace of Versailles&quot;</span>,
493
- <span class="ruby-string">&quot;city&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;Versailles&quot;</span>,
494
- <span class="ruby-string">&quot;country&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;France&quot;</span>,
495
- <span class="ruby-string">&quot;postal_code&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;78000&quot;</span>
496
- }
497
- }
465
+ record_class: &quot;CLASS.NAME&quot;,
466
+ previous_attrs: { attrs: { &quot;KEY&quot; =&gt; &quot;VALUE&quot;, ... } },
467
+ current_attrs: { attrs: { &quot;KEY&quot; =&gt; &quot;VALUE&quot;, ... } }
498
468
  }
499
469
  ]
500
- }
501
- </pre>
470
+ }</pre>
502
471
 
503
472
  <div class="method-source-code" id="update_activity_attrs-source">
504
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 132</span>
473
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 72</span>
505
474
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">update_activity_attrs</span>
506
475
  {
507
476
  <span class="ruby-value">update_attrs:</span>,
@@ -531,10 +500,10 @@
531
500
  </div>
532
501
 
533
502
  <div class="method-description">
534
-
503
+ <p>Returns the key for the actor.</p>
535
504
 
536
505
  <div class="method-source-code" id="actor_key-source">
537
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 276</span>
506
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 224</span>
538
507
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">actor_key</span>
539
508
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">actor</span>.<span class="ruby-identifier">nil?</span>
540
509
 
@@ -556,10 +525,10 @@
556
525
  </div>
557
526
 
558
527
  <div class="method-description">
559
-
528
+ <p>Validates that the activity has at least one payload.</p>
560
529
 
561
530
  <div class="method-source-code" id="must_have_at_least_one_payload-source">
562
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 282</span>
531
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 231</span>
563
532
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">must_have_at_least_one_payload</span>
564
533
  <span class="ruby-identifier">errors</span>.<span class="ruby-identifier">add</span>(<span class="ruby-value">:payloads</span>, <span class="ruby-string">&#39;must have at least one payload&#39;</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">payloads</span>.<span class="ruby-identifier">empty?</span>
565
534
  <span class="ruby-keyword">end</span></pre>
@@ -579,10 +548,10 @@
579
548
  </div>
580
549
 
581
550
  <div class="method-description">
582
-
551
+ <p>Returns payloads sorted by :payload_type.</p>
583
552
 
584
553
  <div class="method-source-code" id="ordered_payloads-source">
585
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 266</span>
554
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 212</span>
586
555
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">ordered_payloads</span>
587
556
  <span class="ruby-identifier">payloads</span>.<span class="ruby-identifier">order</span>(<span class="ruby-value">:payload_type</span>)
588
557
  <span class="ruby-keyword">end</span></pre>
@@ -602,10 +571,10 @@
602
571
  </div>
603
572
 
604
573
  <div class="method-description">
605
-
574
+ <p>Returns the previous association attributes.</p>
606
575
 
607
576
  <div class="method-source-code" id="previous_associations_attrs-source">
608
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 262</span>
577
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 207</span>
609
578
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">previous_associations_attrs</span>
610
579
  <span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span>[<span class="ruby-value">:payload_type</span>] <span class="ruby-operator">==</span> <span class="ruby-string">&#39;previous_association&#39;</span> }
611
580
  <span class="ruby-keyword">end</span></pre>
@@ -625,10 +594,10 @@
625
594
  </div>
626
595
 
627
596
  <div class="method-description">
628
-
597
+ <p>Returns the primary payload.</p>
629
598
 
630
599
  <div class="method-source-code" id="primary_payload-source">
631
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 246</span>
600
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 189</span>
632
601
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">primary_payload</span>
633
602
  <span class="ruby-identifier">ordered_payloads</span>.<span class="ruby-identifier">find</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span>.<span class="ruby-identifier">payload_type</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;primary_payload&#39;</span> }
634
603
  <span class="ruby-keyword">end</span></pre>
@@ -648,10 +617,10 @@
648
617
  </div>
649
618
 
650
619
  <div class="method-description">
651
-
620
+ <p>Returns the key for the logged record.</p>
652
621
 
653
622
  <div class="method-source-code" id="record_key-source">
654
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 270</span>
623
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 217</span>
655
624
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">record_key</span>
656
625
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">record</span>.<span class="ruby-identifier">nil?</span>
657
626
 
@@ -673,10 +642,10 @@
673
642
  </div>
674
643
 
675
644
  <div class="method-description">
676
-
645
+ <p>Returns the attributes for the update+payload.</p>
677
646
 
678
647
  <div class="method-source-code" id="update_attrs-source">
679
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 238</span>
648
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 180</span>
680
649
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">update_attrs</span>
681
650
  <span class="ruby-identifier">update_payload_attrs</span> = <span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">find</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span>[<span class="ruby-value">:payload_type</span>] <span class="ruby-operator">==</span> <span class="ruby-string">&#39;update_payload&#39;</span> }
682
651
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">update_payload_attrs</span>
@@ -700,19 +669,19 @@
700
669
  </div>
701
670
 
702
671
  <div class="method-description">
703
-
672
+ <p>Returns the attributes for the updated relations.</p>
704
673
 
705
674
  <div class="method-source-code" id="updated_relations_attrs-source">
706
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 250</span>
675
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 194</span>
707
676
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">updated_relations_attrs</span>
708
- <span class="ruby-identifier">grouped_associations</span> = <span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">group_by</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span>[<span class="ruby-value">:record_class</span>] }
677
+ <span class="ruby-identifier">grouped_associations</span> = <span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">group_by</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span>[<span class="ruby-value">:record_type</span>] }
709
678
 
710
- <span class="ruby-identifier">grouped_associations</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">record_class</span>, <span class="ruby-identifier">payloads</span><span class="ruby-operator">|</span>
679
+ <span class="ruby-identifier">grouped_associations</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">record_type</span>, <span class="ruby-identifier">payloads</span><span class="ruby-operator">|</span>
711
680
  <span class="ruby-identifier">previous_attrs</span> = <span class="ruby-identifier">payloads</span>.<span class="ruby-identifier">find</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span>[<span class="ruby-value">:payload_type</span>] <span class="ruby-operator">==</span> <span class="ruby-string">&#39;previous_association&#39;</span> }
712
681
  <span class="ruby-identifier">current_attrs</span> = <span class="ruby-identifier">payloads</span>.<span class="ruby-identifier">find</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span>[<span class="ruby-value">:payload_type</span>] <span class="ruby-operator">==</span> <span class="ruby-string">&#39;current_association&#39;</span> }
713
682
  <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">previous_attrs</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">current_attrs</span>.<span class="ruby-identifier">nil?</span>
714
683
 
715
- { <span class="ruby-value">record_class:</span>, <span class="ruby-value">previous_attrs:</span>, <span class="ruby-value">current_attrs:</span> }
684
+ { <span class="ruby-value">record_type:</span>, <span class="ruby-value">previous_attrs:</span>, <span class="ruby-value">current_attrs:</span> }
716
685
  <span class="ruby-keyword">end</span>.<span class="ruby-identifier">compact</span>
717
686
  <span class="ruby-keyword">end</span></pre>
718
687
  </div>
@@ -136,7 +136,7 @@
136
136
  </pre>
137
137
 
138
138
  <div class="method-source-code" id="for_class-source">
139
- <pre><span class="ruby-comment"># File lib/loggable_activity/configuration.rb, line 27</span>
139
+ <pre><span class="ruby-comment"># File lib/loggable_activity/configuration.rb, line 28</span>
140
140
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">for_class</span>(<span class="ruby-identifier">class_name</span>)
141
141
  <span class="ruby-ivar">@config_data</span>[<span class="ruby-identifier">class_name</span>]
142
142
  <span class="ruby-keyword">end</span></pre>
@@ -156,10 +156,10 @@
156
156
  </div>
157
157
 
158
158
  <div class="method-description">
159
-
159
+ <p>Loads the configuration file</p>
160
160
 
161
161
  <div class="method-source-code" id="load_config_file-source">
162
- <pre><span class="ruby-comment"># File lib/loggable_activity/configuration.rb, line 6</span>
162
+ <pre><span class="ruby-comment"># File lib/loggable_activity/configuration.rb, line 7</span>
163
163
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">load_config_file</span>(<span class="ruby-identifier">config_file_path</span>)
164
164
  <span class="ruby-ivar">@config_data</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load_file</span>(<span class="ruby-identifier">config_file_path</span>)
165
165
  <span class="ruby-keyword">end</span></pre>
@@ -107,10 +107,10 @@
107
107
  </div>
108
108
 
109
109
  <div class="method-description">
110
-
110
+ <p>Returns true if the given value is blank</p>
111
111
 
112
112
  <div class="method-source-code" id="blank-3F-source">
113
- <pre><span class="ruby-comment"># File lib/loggable_activity/encryption.rb, line 65</span>
113
+ <pre><span class="ruby-comment"># File lib/loggable_activity/encryption.rb, line 69</span>
114
114
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">blank?</span>(<span class="ruby-identifier">value</span>)
115
115
  <span class="ruby-identifier">value</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:empty?</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">:</span> <span class="ruby-operator">!</span><span class="ruby-identifier">value</span>
116
116
  <span class="ruby-keyword">end</span></pre>
@@ -148,7 +148,7 @@
148
148
  <span class="ruby-keyword">return</span> <span class="ruby-string">&#39;&#39;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">encoded_key</span>.<span class="ruby-identifier">nil?</span>
149
149
 
150
150
  <span class="ruby-identifier">encryption_key</span> = <span class="ruby-constant">Base64</span>.<span class="ruby-identifier">decode64</span>(<span class="ruby-identifier">encoded_key</span>)
151
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">EncryptionError</span>, <span class="ruby-string">&#39;Decryption failed: Invalid encryption key length&#39;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">encryption_key</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">==</span> <span class="ruby-value">32</span>
151
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">EncryptionError</span>, <span class="ruby-node">&quot;Decryption failed: Invalid encoded_key length: #{encryption_key.bytesize}&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">encryption_key</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">==</span> <span class="ruby-value">32</span>
152
152
 
153
153
  <span class="ruby-identifier">cipher</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">Cipher</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;AES-256-CBC&#39;</span>).<span class="ruby-identifier">decrypt</span>
154
154
  <span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">key</span> = <span class="ruby-identifier">encryption_key</span>
@@ -160,6 +160,9 @@
160
160
  <span class="ruby-identifier">decrypted_data</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-string">&#39;UTF-8&#39;</span>)
161
161
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">Cipher</span><span class="ruby-operator">::</span><span class="ruby-constant">CipherError</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">e</span>
162
162
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">EncryptionError</span>, <span class="ruby-node">&quot;Decryption failed: #{e.message}&quot;</span>
163
+ <span class="ruby-keyword">rescue</span> <span class="ruby-constant">EncryptionError</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">e</span>
164
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
165
+ <span class="ruby-string">&#39;*** DECRYPTION FAILED ***&#39;</span>
163
166
  <span class="ruby-keyword">end</span></pre>
164
167
  </div>
165
168
  </div>
@@ -195,7 +198,7 @@
195
198
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">encoded_key</span>.<span class="ruby-identifier">nil?</span>
196
199
 
197
200
  <span class="ruby-identifier">encryption_key</span> = <span class="ruby-constant">Base64</span>.<span class="ruby-identifier">decode64</span>(<span class="ruby-identifier">encoded_key</span>)
198
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">EncryptionError</span>, <span class="ruby-node">&quot;Encryption failed: Invalid encryption key length #{encryption_key.bytesize}&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">encryption_key</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">==</span> <span class="ruby-value">32</span>
201
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">EncryptionError</span>, <span class="ruby-node">&quot;Encryption failed: Invalid encoded_key length #{encryption_key.bytesize}&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">encryption_key</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">==</span> <span class="ruby-value">32</span>
199
202
 
200
203
  <span class="ruby-identifier">cipher</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">Cipher</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;AES-256-CBC&#39;</span>).<span class="ruby-identifier">encrypt</span>
201
204
  <span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">key</span> = <span class="ruby-identifier">encryption_key</span>