loggable_activity 0.1.56 → 0.1.58
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/.rubocop.yml +10 -1
- data/CHANGELOG.md +9 -0
- data/GETTING-STARTED.md +8 -47
- data/PAYLOAD_EXAMPLE.md +63 -0
- data/docs/LoggableActivity/Activity.html +92 -241
- data/docs/LoggableActivity/Configuration.html +162 -15
- data/docs/LoggableActivity/ConfigurationError.html +148 -0
- data/docs/LoggableActivity/DataOwner.html +138 -0
- data/docs/LoggableActivity/Encryption.html +18 -14
- data/docs/LoggableActivity/EncryptionError.html +47 -1
- data/docs/LoggableActivity/EncryptionKey.html +54 -35
- data/docs/LoggableActivity/Error.html +48 -0
- data/docs/LoggableActivity/Hooks.html +221 -89
- data/docs/LoggableActivity/Payload.html +103 -27
- data/docs/LoggableActivity/Services/BasePayloadsBuilder.html +442 -0
- data/docs/LoggableActivity/Services/DestroyPayloadsBuilder.html +395 -0
- data/docs/LoggableActivity/Services/PayloadsBuilder.html +342 -0
- data/docs/LoggableActivity/Services/UpdatePayloadsBuilder.html +490 -0
- data/docs/LoggableActivity/Services.html +93 -0
- data/docs/created.rid +14 -10
- data/docs/index.html +10 -2
- data/docs/js/navigation.js.gz +0 -0
- data/docs/js/search_index.js +1 -1
- data/docs/js/search_index.js.gz +0 -0
- data/docs/js/searcher.js.gz +0 -0
- data/docs/table_of_contents.html +253 -85
- data/lib/generators/loggable_activity/install_generator.rb +2 -18
- data/lib/generators/loggable_activity/templates/binary_ids/create_loggable_activities.rb +9 -10
- data/lib/generators/loggable_activity/templates/create_loggable_activities.rb +16 -13
- data/lib/loggable_activity/activity.rb +53 -102
- data/lib/loggable_activity/configuration.rb +60 -3
- data/lib/loggable_activity/data_owner.rb +18 -0
- data/lib/loggable_activity/encryption.rb +14 -14
- data/lib/loggable_activity/encryption_key.rb +26 -25
- data/lib/loggable_activity/error.rb +34 -0
- data/lib/loggable_activity/hooks.rb +78 -43
- data/lib/loggable_activity/payload.rb +70 -20
- data/lib/loggable_activity/services/base_payloads_builder.rb +127 -0
- data/lib/loggable_activity/services/destroy_payloads_builder.rb +127 -0
- data/lib/loggable_activity/services/payloads_builder.rb +98 -0
- data/lib/loggable_activity/services/update_payloads_builder.rb +168 -0
- data/lib/loggable_activity/version.rb +1 -1
- data/lib/loggable_activity.rb +6 -6
- data/lib/schemas/config_schema.json +90 -0
- metadata +37 -26
- data/docs/LoggableActivity/PayloadsBuilder.html +0 -441
- data/docs/LoggableActivity/UpdatePayloadsBuilder.html +0 -424
- data/lib/generators/loggable_activity/install_templates_generator.rb +0 -105
- data/lib/generators/loggable_activity/templates/helpers/activity_helper.rb +0 -37
- data/lib/generators/loggable_activity/templates/helpers/router.rb +0 -52
- data/lib/generators/loggable_activity/templates/helpers/routes_helper.rb +0 -20
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_create.html.erb +0 -23
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_create.html.slim +0 -18
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_destroy.html.erb +0 -18
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_destroy.html.slim +0 -17
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_show.html.erb +0 -18
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_show.html.slim +0 -17
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_update.html.erb +0 -18
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_update.html.slim +0 -12
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_activity_info.html.erb +0 -12
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_activity_info.html.slim +0 -11
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_list_attrs.html.erb +0 -8
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_list_attrs.html.slim +0 -6
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_update_attrs.html.erb +0 -17
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_update_attrs.html.slim +0 -14
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_updated_relations.html.erb +0 -23
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_updated_relations.html.slim +0 -21
- data/lib/loggable_activity/payloads_builder.rb +0 -153
- data/lib/loggable_activity/update_payloads_builder.rb +0 -127
@@ -72,8 +72,13 @@
|
|
72
72
|
<h3>Methods</h3>
|
73
73
|
|
74
74
|
<ul class="link-list" role="directory">
|
75
|
+
<li ><a href="#method-c-current_user_model_name">::current_user_model_name</a>
|
76
|
+
<li ><a href="#method-c-fetch_current_user_name_from">::fetch_current_user_name_from</a>
|
75
77
|
<li ><a href="#method-c-for_class">::for_class</a>
|
76
78
|
<li ><a href="#method-c-load_config_file">::load_config_file</a>
|
79
|
+
<li ><a href="#method-c-load_schema">::load_schema</a>
|
80
|
+
<li ><a href="#method-c-loaded-3F">::loaded?</a>
|
81
|
+
<li ><a href="#method-c-validate_config_file">::validate_config_file</a>
|
77
82
|
</ul>
|
78
83
|
</div>
|
79
84
|
|
@@ -89,12 +94,30 @@
|
|
89
94
|
|
90
95
|
<p>This class is used to load the configuration file located at config/loggable_activity.yml</p>
|
91
96
|
|
97
|
+
<p>When the LoggableActivity::Hook is included in a model it takes the model’s name and find the configuration for that model in the configuration file.</p>
|
98
|
+
|
92
99
|
</section>
|
93
100
|
|
94
101
|
<section id="5Buntitled-5D" class="documentation-section">
|
95
102
|
|
96
103
|
|
97
104
|
|
105
|
+
<section class="attribute-method-details" class="method-section">
|
106
|
+
<header>
|
107
|
+
<h3>Attributes</h3>
|
108
|
+
</header>
|
109
|
+
|
110
|
+
<div id="attribute-c-config_data" class="method-detail">
|
111
|
+
<div class="method-heading attribute-method-heading">
|
112
|
+
<span class="method-name">config_data</span><span
|
113
|
+
class="attribute-access-type">[R]</span>
|
114
|
+
</div>
|
115
|
+
|
116
|
+
<div class="method-description">
|
117
|
+
<p>@return [Hash]</p>
|
118
|
+
</div>
|
119
|
+
</div>
|
120
|
+
</section>
|
98
121
|
|
99
122
|
|
100
123
|
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
@@ -102,6 +125,52 @@
|
|
102
125
|
<h3>Public Class Methods</h3>
|
103
126
|
</header>
|
104
127
|
|
128
|
+
<div id="method-c-current_user_model_name" class="method-detail ">
|
129
|
+
<div class="method-header">
|
130
|
+
<div class="method-heading">
|
131
|
+
<span class="method-name">current_user_model_name</span><span
|
132
|
+
class="method-args">()</span>
|
133
|
+
<span class="method-click-advice">click to toggle source</span>
|
134
|
+
</div>
|
135
|
+
</div>
|
136
|
+
|
137
|
+
<div class="method-description">
|
138
|
+
<p>Returns the name of the model to use for the current user.</p>
|
139
|
+
|
140
|
+
<div class="method-source-code" id="current_user_model_name-source">
|
141
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/configuration.rb, line 86</span>
|
142
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">current_user_model_name</span>
|
143
|
+
<span class="ruby-ivar">@config_data</span>[<span class="ruby-string">'current_user_model_name'</span>]
|
144
|
+
<span class="ruby-keyword">end</span></pre>
|
145
|
+
</div>
|
146
|
+
</div>
|
147
|
+
|
148
|
+
|
149
|
+
</div>
|
150
|
+
|
151
|
+
<div id="method-c-fetch_current_user_name_from" class="method-detail ">
|
152
|
+
<div class="method-header">
|
153
|
+
<div class="method-heading">
|
154
|
+
<span class="method-name">fetch_current_user_name_from</span><span
|
155
|
+
class="method-args">()</span>
|
156
|
+
<span class="method-click-advice">click to toggle source</span>
|
157
|
+
</div>
|
158
|
+
</div>
|
159
|
+
|
160
|
+
<div class="method-description">
|
161
|
+
<p>Returns the name of the field or method to use for the actor’s display name.</p>
|
162
|
+
|
163
|
+
<div class="method-source-code" id="fetch_current_user_name_from-source">
|
164
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/configuration.rb, line 81</span>
|
165
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">fetch_current_user_name_from</span>
|
166
|
+
<span class="ruby-ivar">@config_data</span>[<span class="ruby-string">'fetch_current_user_name_from'</span>]
|
167
|
+
<span class="ruby-keyword">end</span></pre>
|
168
|
+
</div>
|
169
|
+
</div>
|
170
|
+
|
171
|
+
|
172
|
+
</div>
|
173
|
+
|
105
174
|
<div id="method-c-for_class" class="method-detail ">
|
106
175
|
<div class="method-header">
|
107
176
|
<div class="method-heading">
|
@@ -116,27 +185,27 @@
|
|
116
185
|
|
117
186
|
<p>Example:</p>
|
118
187
|
|
119
|
-
<pre class="ruby"><span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">for_class</span>(<span class="ruby-string">'User'</span>)
|
188
|
+
<pre class="ruby"><span class="ruby-operator">::</span><span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">for_class</span>(<span class="ruby-string">'User'</span>)
|
120
189
|
</pre>
|
121
190
|
|
122
191
|
<p>Returns:</p>
|
123
192
|
|
124
|
-
<pre
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
193
|
+
<pre>{
|
194
|
+
"fetch_record_name_from": "full_name",
|
195
|
+
"loggable_attrs": [
|
196
|
+
"first_name",
|
197
|
+
"last_name",
|
129
198
|
],
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
]
|
135
|
-
|
136
|
-
</pre>
|
199
|
+
"auto_log": [
|
200
|
+
"create",
|
201
|
+
"update",
|
202
|
+
"destroy"
|
203
|
+
],
|
204
|
+
....
|
205
|
+
}</pre>
|
137
206
|
|
138
207
|
<div class="method-source-code" id="for_class-source">
|
139
|
-
<pre><span class="ruby-comment"># File lib/loggable_activity/configuration.rb, line
|
208
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/configuration.rb, line 76</span>
|
140
209
|
<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
210
|
<span class="ruby-ivar">@config_data</span>[<span class="ruby-identifier">class_name</span>]
|
142
211
|
<span class="ruby-keyword">end</span></pre>
|
@@ -159,9 +228,87 @@
|
|
159
228
|
<p>Loads the configuration file</p>
|
160
229
|
|
161
230
|
<div class="method-source-code" id="load_config_file-source">
|
162
|
-
<pre><span class="ruby-comment"># File lib/loggable_activity/configuration.rb, line
|
231
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/configuration.rb, line 24</span>
|
163
232
|
<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
233
|
<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>)
|
234
|
+
<span class="ruby-identifier">validate_config_file</span>
|
235
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>
|
236
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ConfigurationError</span>, <span class="ruby-string">'config/loggable_activity.yaml not found'</span>
|
237
|
+
<span class="ruby-keyword">end</span></pre>
|
238
|
+
</div>
|
239
|
+
</div>
|
240
|
+
|
241
|
+
|
242
|
+
</div>
|
243
|
+
|
244
|
+
<div id="method-c-load_schema" class="method-detail ">
|
245
|
+
<div class="method-header">
|
246
|
+
<div class="method-heading">
|
247
|
+
<span class="method-name">load_schema</span><span
|
248
|
+
class="method-args">()</span>
|
249
|
+
<span class="method-click-advice">click to toggle source</span>
|
250
|
+
</div>
|
251
|
+
</div>
|
252
|
+
|
253
|
+
<div class="method-description">
|
254
|
+
<p>Loads the schema file for the configuration file</p>
|
255
|
+
|
256
|
+
<div class="method-source-code" id="load_schema-source">
|
257
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/configuration.rb, line 32</span>
|
258
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">load_schema</span>
|
259
|
+
<span class="ruby-identifier">schema_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">__dir__</span>, <span class="ruby-string">'..'</span>, <span class="ruby-string">'schemas'</span>, <span class="ruby-string">'config_schema.json'</span>)
|
260
|
+
<span class="ruby-constant">JSON</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">schema_path</span>))
|
261
|
+
<span class="ruby-keyword">end</span></pre>
|
262
|
+
</div>
|
263
|
+
</div>
|
264
|
+
|
265
|
+
|
266
|
+
</div>
|
267
|
+
|
268
|
+
<div id="method-c-loaded-3F" class="method-detail ">
|
269
|
+
<div class="method-header">
|
270
|
+
<div class="method-heading">
|
271
|
+
<span class="method-name">loaded?</span><span
|
272
|
+
class="method-args">()</span>
|
273
|
+
<span class="method-click-advice">click to toggle source</span>
|
274
|
+
</div>
|
275
|
+
</div>
|
276
|
+
|
277
|
+
<div class="method-description">
|
278
|
+
<p>Returns true if the configuration file has been loaded</p>
|
279
|
+
|
280
|
+
<div class="method-source-code" id="loaded-3F-source">
|
281
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/configuration.rb, line 48</span>
|
282
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">loaded?</span>
|
283
|
+
<span class="ruby-operator">!</span><span class="ruby-ivar">@config_data</span>.<span class="ruby-identifier">nil?</span>
|
284
|
+
<span class="ruby-keyword">end</span></pre>
|
285
|
+
</div>
|
286
|
+
</div>
|
287
|
+
|
288
|
+
|
289
|
+
</div>
|
290
|
+
|
291
|
+
<div id="method-c-validate_config_file" class="method-detail ">
|
292
|
+
<div class="method-header">
|
293
|
+
<div class="method-heading">
|
294
|
+
<span class="method-name">validate_config_file</span><span
|
295
|
+
class="method-args">()</span>
|
296
|
+
<span class="method-click-advice">click to toggle source</span>
|
297
|
+
</div>
|
298
|
+
</div>
|
299
|
+
|
300
|
+
<div class="method-description">
|
301
|
+
<p>Validates the configuration file againss the schema</p>
|
302
|
+
|
303
|
+
<div class="method-source-code" id="validate_config_file-source">
|
304
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/configuration.rb, line 38</span>
|
305
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">validate_config_file</span>
|
306
|
+
<span class="ruby-identifier">schema</span> = <span class="ruby-identifier">load_schema</span>
|
307
|
+
<span class="ruby-identifier">errors</span> = <span class="ruby-constant">JSON</span><span class="ruby-operator">::</span><span class="ruby-constant">Validator</span>.<span class="ruby-identifier">fully_validate</span>(<span class="ruby-identifier">schema</span>, <span class="ruby-ivar">@config_data</span>)
|
308
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">errors</span>.<span class="ruby-identifier">any?</span>
|
309
|
+
|
310
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ConfigurationError</span>,
|
311
|
+
<span class="ruby-node">"config/loggable_activity.yaml is invalid: #{errors.join(', ')}"</span>
|
165
312
|
<span class="ruby-keyword">end</span></pre>
|
166
313
|
</div>
|
167
314
|
</div>
|
@@ -0,0 +1,148 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>class LoggableActivity::ConfigurationError - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "../";
|
11
|
+
var index_rel_prefix = "../";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="../js/navigation.js" defer></script>
|
15
|
+
<script src="../js/search.js" defer></script>
|
16
|
+
<script src="../js/search_index.js" defer></script>
|
17
|
+
<script src="../js/searcher.js" defer></script>
|
18
|
+
<script src="../js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="../css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="../css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
<body id="top" role="document" class="class">
|
25
|
+
<nav role="navigation">
|
26
|
+
<div id="project-navigation">
|
27
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
28
|
+
<h2>
|
29
|
+
<a href="../index.html" rel="home">Home</a>
|
30
|
+
</h2>
|
31
|
+
|
32
|
+
<div id="table-of-contents-navigation">
|
33
|
+
<a href="../table_of_contents.html#pages">Pages</a>
|
34
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
35
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
40
|
+
<form action="#" method="get" accept-charset="utf-8">
|
41
|
+
<div id="search-field-wrapper">
|
42
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
43
|
+
aria-autocomplete="list" aria-controls="search-results"
|
44
|
+
type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
|
45
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<ul id="search-results" aria-label="Search Results"
|
49
|
+
aria-busy="false" aria-expanded="false"
|
50
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
51
|
+
</form>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
</div>
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
<div id="class-metadata">
|
59
|
+
|
60
|
+
|
61
|
+
<div id="parent-class-section" class="nav-section">
|
62
|
+
<h3>Parent</h3>
|
63
|
+
|
64
|
+
<p class="link">StandardError
|
65
|
+
</div>
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
<!-- Method Quickref -->
|
71
|
+
<div id="method-list-section" class="nav-section">
|
72
|
+
<h3>Methods</h3>
|
73
|
+
|
74
|
+
<ul class="link-list" role="directory">
|
75
|
+
<li class="calls-super" ><a href="#method-c-new">::new</a>
|
76
|
+
</ul>
|
77
|
+
</div>
|
78
|
+
|
79
|
+
</div>
|
80
|
+
</nav>
|
81
|
+
|
82
|
+
<main role="main" aria-labelledby="class-LoggableActivity::ConfigurationError">
|
83
|
+
<h1 id="class-LoggableActivity::ConfigurationError" class="class">
|
84
|
+
class LoggableActivity::ConfigurationError
|
85
|
+
</h1>
|
86
|
+
|
87
|
+
<section class="description">
|
88
|
+
|
89
|
+
<p>This class is used to load the configuration file located at config/loggable_activity.yml</p>
|
90
|
+
|
91
|
+
<p>This class is used to load the configuration file located at config/loggable_activity.yml</p>
|
92
|
+
|
93
|
+
</section>
|
94
|
+
|
95
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
102
|
+
<header>
|
103
|
+
<h3>Public Class Methods</h3>
|
104
|
+
</header>
|
105
|
+
|
106
|
+
<div id="method-c-new" class="method-detail ">
|
107
|
+
<div class="method-header">
|
108
|
+
<div class="method-heading">
|
109
|
+
<span class="method-name">new</span><span
|
110
|
+
class="method-args">(msg = '')</span>
|
111
|
+
<span class="method-click-advice">click to toggle source</span>
|
112
|
+
</div>
|
113
|
+
</div>
|
114
|
+
|
115
|
+
<div class="method-description">
|
116
|
+
|
117
|
+
<div class="method-calls-super">
|
118
|
+
Calls superclass method
|
119
|
+
|
120
|
+
</div>
|
121
|
+
|
122
|
+
<div class="method-source-code" id="new-source">
|
123
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/configuration.rb, line 10</span>
|
124
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">msg</span> = <span class="ruby-string">''</span>)
|
125
|
+
<span class="ruby-comment"># https://api.loggable_activity.com/msg</span>
|
126
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">'---------------- LOGGABLE ACTIVITY -----------------'</span>
|
127
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">msg</span>
|
128
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">'----------------------------------------------------'</span>
|
129
|
+
<span class="ruby-keyword">super</span>(<span class="ruby-identifier">msg</span>)
|
130
|
+
<span class="ruby-keyword">end</span></pre>
|
131
|
+
</div>
|
132
|
+
</div>
|
133
|
+
|
134
|
+
|
135
|
+
</div>
|
136
|
+
|
137
|
+
</section>
|
138
|
+
|
139
|
+
</section>
|
140
|
+
</main>
|
141
|
+
|
142
|
+
|
143
|
+
<footer id="validator-badges" role="contentinfo">
|
144
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
145
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.6.2.
|
146
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
147
|
+
</footer>
|
148
|
+
|
@@ -0,0 +1,138 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>class LoggableActivity::DataOwner - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "../";
|
11
|
+
var index_rel_prefix = "../";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="../js/navigation.js" defer></script>
|
15
|
+
<script src="../js/search.js" defer></script>
|
16
|
+
<script src="../js/search_index.js" defer></script>
|
17
|
+
<script src="../js/searcher.js" defer></script>
|
18
|
+
<script src="../js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="../css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="../css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
<body id="top" role="document" class="class">
|
25
|
+
<nav role="navigation">
|
26
|
+
<div id="project-navigation">
|
27
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
28
|
+
<h2>
|
29
|
+
<a href="../index.html" rel="home">Home</a>
|
30
|
+
</h2>
|
31
|
+
|
32
|
+
<div id="table-of-contents-navigation">
|
33
|
+
<a href="../table_of_contents.html#pages">Pages</a>
|
34
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
35
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
40
|
+
<form action="#" method="get" accept-charset="utf-8">
|
41
|
+
<div id="search-field-wrapper">
|
42
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
43
|
+
aria-autocomplete="list" aria-controls="search-results"
|
44
|
+
type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
|
45
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<ul id="search-results" aria-label="Search Results"
|
49
|
+
aria-busy="false" aria-expanded="false"
|
50
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
51
|
+
</form>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
</div>
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
<div id="class-metadata">
|
59
|
+
|
60
|
+
|
61
|
+
<div id="parent-class-section" class="nav-section">
|
62
|
+
<h3>Parent</h3>
|
63
|
+
|
64
|
+
<p class="link">ActiveRecord::Base
|
65
|
+
</div>
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
<!-- Method Quickref -->
|
71
|
+
<div id="method-list-section" class="nav-section">
|
72
|
+
<h3>Methods</h3>
|
73
|
+
|
74
|
+
<ul class="link-list" role="directory">
|
75
|
+
<li ><a href="#method-i-mark_as_deleted-21">#mark_as_deleted!</a>
|
76
|
+
</ul>
|
77
|
+
</div>
|
78
|
+
|
79
|
+
</div>
|
80
|
+
</nav>
|
81
|
+
|
82
|
+
<main role="main" aria-labelledby="class-LoggableActivity::DataOwner">
|
83
|
+
<h1 id="class-LoggableActivity::DataOwner" class="class">
|
84
|
+
class LoggableActivity::DataOwner
|
85
|
+
</h1>
|
86
|
+
|
87
|
+
<section class="description">
|
88
|
+
|
89
|
+
<p>This class represends an additional data owner for a record. For it to kick in, the data_owner configuration has to be set to true in the loggable_activity.yaml file.</p>
|
90
|
+
|
91
|
+
</section>
|
92
|
+
|
93
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
100
|
+
<header>
|
101
|
+
<h3>Public Instance Methods</h3>
|
102
|
+
</header>
|
103
|
+
|
104
|
+
<div id="method-i-mark_as_deleted-21" class="method-detail ">
|
105
|
+
<div class="method-header">
|
106
|
+
<div class="method-heading">
|
107
|
+
<span class="method-name">mark_as_deleted!</span><span
|
108
|
+
class="method-args">()</span>
|
109
|
+
<span class="method-click-advice">click to toggle source</span>
|
110
|
+
</div>
|
111
|
+
</div>
|
112
|
+
|
113
|
+
<div class="method-description">
|
114
|
+
<p>When a record is deleted, all data owner added to the record is also deleted.</p>
|
115
|
+
|
116
|
+
<div class="method-source-code" id="mark_as_deleted-21-source">
|
117
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/data_owner.rb, line 15</span>
|
118
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">mark_as_deleted!</span>
|
119
|
+
<span class="ruby-identifier">encryption_key</span>.<span class="ruby-identifier">mark_as_deleted!</span>
|
120
|
+
<span class="ruby-keyword">end</span></pre>
|
121
|
+
</div>
|
122
|
+
</div>
|
123
|
+
|
124
|
+
|
125
|
+
</div>
|
126
|
+
|
127
|
+
</section>
|
128
|
+
|
129
|
+
</section>
|
130
|
+
</main>
|
131
|
+
|
132
|
+
|
133
|
+
<footer id="validator-badges" role="contentinfo">
|
134
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
135
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.6.2.
|
136
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
137
|
+
</footer>
|
138
|
+
|
@@ -124,7 +124,7 @@
|
|
124
124
|
<div class="method-header">
|
125
125
|
<div class="method-heading">
|
126
126
|
<span class="method-name">decrypt</span><span
|
127
|
-
class="method-args">(data,
|
127
|
+
class="method-args">(data, secret_key)</span>
|
128
128
|
<span class="method-click-advice">click to toggle source</span>
|
129
129
|
</div>
|
130
130
|
</div>
|
@@ -134,7 +134,7 @@
|
|
134
134
|
|
135
135
|
<p>Example:</p>
|
136
136
|
|
137
|
-
<pre class="ruby"><span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">Encryption</span>.<span class="ruby-identifier">decrypt</span>(<span class="ruby-string">'SOME_ENCRYPTED_STRING'</span>, <span class="ruby-string">'SECRET_KEY'</span>)
|
137
|
+
<pre class="ruby"><span class="ruby-operator">::</span><span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">Encryption</span>.<span class="ruby-identifier">decrypt</span>(<span class="ruby-string">'SOME_ENCRYPTED_STRING'</span>, <span class="ruby-string">'SECRET_KEY'</span>)
|
138
138
|
</pre>
|
139
139
|
|
140
140
|
<p>Returns:</p>
|
@@ -143,15 +143,17 @@
|
|
143
143
|
</pre>
|
144
144
|
|
145
145
|
<div class="method-source-code" id="decrypt-source">
|
146
|
-
<pre><span class="ruby-comment"># File lib/loggable_activity/encryption.rb, line
|
147
|
-
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">decrypt</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">
|
148
|
-
<span class="ruby-keyword">return</span> <span class="ruby-
|
146
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/encryption.rb, line 44</span>
|
147
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">decrypt</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">secret_key</span>)
|
148
|
+
<span class="ruby-keyword">return</span> <span class="ruby-constant">I18n</span>.<span class="ruby-identifier">t</span>(<span class="ruby-string">'loggable.activity.deleted'</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">secret_key</span>.<span class="ruby-identifier">nil?</span>
|
149
|
+
<span class="ruby-keyword">return</span> <span class="ruby-string">''</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">blank?</span>
|
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">
|
151
|
+
<span class="ruby-identifier">encryption_key</span> = <span class="ruby-constant">Base64</span>.<span class="ruby-identifier">decode64</span>(<span class="ruby-identifier">secret_key</span>)
|
151
152
|
<span class="ruby-identifier">raise</span> <span class="ruby-constant">EncryptionError</span>, <span class="ruby-node">"Decryption failed: Invalid encoded_key length: #{encryption_key.bytesize}"</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
153
|
|
153
154
|
<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">'AES-256-CBC'</span>).<span class="ruby-identifier">decrypt</span>
|
154
155
|
<span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">key</span> = <span class="ruby-identifier">encryption_key</span>
|
156
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">EncryptionError</span>, <span class="ruby-string">'Decryption failed: Invalid data length'</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">></span> <span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">iv_len</span>
|
155
157
|
|
156
158
|
<span class="ruby-identifier">raw_data</span> = <span class="ruby-constant">Base64</span>.<span class="ruby-identifier">decode64</span>(<span class="ruby-identifier">data</span>)
|
157
159
|
<span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">iv</span> = <span class="ruby-identifier">raw_data</span>[<span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">iv_len</span>] <span class="ruby-comment"># Extract IV from the beginning of raw_data</span>
|
@@ -159,9 +161,10 @@
|
|
159
161
|
|
160
162
|
<span class="ruby-identifier">decrypted_data</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-string">'UTF-8'</span>)
|
161
163
|
<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">=></span> <span class="ruby-identifier">e</span>
|
162
|
-
<span class="ruby-identifier">
|
164
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"CipherError Decryption failed: #{e.message}"</span>
|
165
|
+
<span class="ruby-string">'*** DECRYPTION FAILED ***'</span>
|
163
166
|
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">EncryptionError</span> <span class="ruby-operator">=></span> <span class="ruby-identifier">e</span>
|
164
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-
|
167
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"EncryptionError failed: #{e.message}"</span>
|
165
168
|
<span class="ruby-string">'*** DECRYPTION FAILED ***'</span>
|
166
169
|
<span class="ruby-keyword">end</span></pre>
|
167
170
|
</div>
|
@@ -174,7 +177,7 @@
|
|
174
177
|
<div class="method-header">
|
175
178
|
<div class="method-heading">
|
176
179
|
<span class="method-name">encrypt</span><span
|
177
|
-
class="method-args">(data,
|
180
|
+
class="method-args">(data, secret_key)</span>
|
178
181
|
<span class="method-click-advice">click to toggle source</span>
|
179
182
|
</div>
|
180
183
|
</div>
|
@@ -184,7 +187,7 @@
|
|
184
187
|
|
185
188
|
<p>Example:</p>
|
186
189
|
|
187
|
-
<pre class="ruby"><span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">Encryption</span>.<span class="ruby-identifier">encrypt</span>(<span class="ruby-string">'my secret data'</span>, <span class="ruby-string">'my secret key'</span>)
|
190
|
+
<pre class="ruby"><span class="ruby-operator">::</span><span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">Encryption</span>.<span class="ruby-identifier">encrypt</span>(<span class="ruby-string">'my secret data'</span>, <span class="ruby-string">'my secret key'</span>)
|
188
191
|
</pre>
|
189
192
|
|
190
193
|
<p>Returns:</p>
|
@@ -193,11 +196,12 @@
|
|
193
196
|
</pre>
|
194
197
|
|
195
198
|
<div class="method-source-code" id="encrypt-source">
|
196
|
-
<pre><span class="ruby-comment"># File lib/loggable_activity/encryption.rb, line
|
197
|
-
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">encrypt</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">
|
198
|
-
<span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">
|
199
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/encryption.rb, line 18</span>
|
200
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">encrypt</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">secret_key</span>)
|
201
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">secret_key</span>.<span class="ruby-identifier">nil?</span>
|
202
|
+
<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>
|
199
203
|
|
200
|
-
<span class="ruby-identifier">encryption_key</span> = <span class="ruby-constant">Base64</span>.<span class="ruby-identifier">decode64</span>(<span class="ruby-identifier">
|
204
|
+
<span class="ruby-identifier">encryption_key</span> = <span class="ruby-constant">Base64</span>.<span class="ruby-identifier">decode64</span>(<span class="ruby-identifier">secret_key</span>)
|
201
205
|
<span class="ruby-identifier">raise</span> <span class="ruby-constant">EncryptionError</span>, <span class="ruby-node">"Encryption failed: Invalid encoded_key length #{encryption_key.bytesize}"</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>
|
202
206
|
|
203
207
|
<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">'AES-256-CBC'</span>).<span class="ruby-identifier">encrypt</span>
|