dh_easy-core 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.travis.yml +7 -0
  4. data/.yardopts +1 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +6 -0
  7. data/LICENSE +21 -0
  8. data/README.md +20 -0
  9. data/Rakefile +22 -0
  10. data/dh_easy-core.gemspec +50 -0
  11. data/doc/DhEasy.html +117 -0
  12. data/doc/DhEasy/Core.html +1590 -0
  13. data/doc/DhEasy/Core/Config.html +311 -0
  14. data/doc/DhEasy/Core/Exception.html +117 -0
  15. data/doc/DhEasy/Core/Exception/OutdatedError.html +135 -0
  16. data/doc/DhEasy/Core/Helper.html +117 -0
  17. data/doc/DhEasy/Core/Helper/Cookie.html +1070 -0
  18. data/doc/DhEasy/Core/Mock.html +282 -0
  19. data/doc/DhEasy/Core/Mock/FakeDb.html +3779 -0
  20. data/doc/DhEasy/Core/Mock/FakeExecutor.html +3289 -0
  21. data/doc/DhEasy/Core/Mock/FakeFinisher.html +160 -0
  22. data/doc/DhEasy/Core/Mock/FakeParser.html +160 -0
  23. data/doc/DhEasy/Core/Mock/FakeSeeder.html +160 -0
  24. data/doc/DhEasy/Core/Plugin.html +117 -0
  25. data/doc/DhEasy/Core/Plugin/CollectionVault.html +299 -0
  26. data/doc/DhEasy/Core/Plugin/ConfigBehavior.html +541 -0
  27. data/doc/DhEasy/Core/Plugin/ContextIntegrator.html +445 -0
  28. data/doc/DhEasy/Core/Plugin/Executor.html +259 -0
  29. data/doc/DhEasy/Core/Plugin/ExecutorBehavior.html +344 -0
  30. data/doc/DhEasy/Core/Plugin/Finisher.html +265 -0
  31. data/doc/DhEasy/Core/Plugin/FinisherBehavior.html +142 -0
  32. data/doc/DhEasy/Core/Plugin/InitializeHook.html +220 -0
  33. data/doc/DhEasy/Core/Plugin/Parser.html +270 -0
  34. data/doc/DhEasy/Core/Plugin/ParserBehavior.html +235 -0
  35. data/doc/DhEasy/Core/Plugin/Seeder.html +674 -0
  36. data/doc/DhEasy/Core/Plugin/SeederBehavior.html +142 -0
  37. data/doc/DhEasy/Core/SmartCollection.html +1087 -0
  38. data/doc/_index.html +364 -0
  39. data/doc/class_list.html +51 -0
  40. data/doc/css/common.css +1 -0
  41. data/doc/css/full_list.css +58 -0
  42. data/doc/css/style.css +496 -0
  43. data/doc/file.README.html +91 -0
  44. data/doc/file_list.html +56 -0
  45. data/doc/frames.html +17 -0
  46. data/doc/index.html +91 -0
  47. data/doc/js/app.js +303 -0
  48. data/doc/js/full_list.js +216 -0
  49. data/doc/js/jquery.js +4 -0
  50. data/doc/method_list.html +939 -0
  51. data/doc/top-level-namespace.html +110 -0
  52. data/lib/dh_easy/core.rb +257 -0
  53. data/lib/dh_easy/core/config.rb +27 -0
  54. data/lib/dh_easy/core/exception.rb +8 -0
  55. data/lib/dh_easy/core/exception/outdated_error.rb +9 -0
  56. data/lib/dh_easy/core/helper.rb +8 -0
  57. data/lib/dh_easy/core/helper/cookie.rb +209 -0
  58. data/lib/dh_easy/core/mock.rb +45 -0
  59. data/lib/dh_easy/core/mock/fake_db.rb +561 -0
  60. data/lib/dh_easy/core/mock/fake_executor.rb +373 -0
  61. data/lib/dh_easy/core/mock/fake_finisher.rb +28 -0
  62. data/lib/dh_easy/core/mock/fake_parser.rb +33 -0
  63. data/lib/dh_easy/core/mock/fake_seeder.rb +28 -0
  64. data/lib/dh_easy/core/plugin.rb +19 -0
  65. data/lib/dh_easy/core/plugin/collection_vault.rb +23 -0
  66. data/lib/dh_easy/core/plugin/config_behavior.rb +43 -0
  67. data/lib/dh_easy/core/plugin/context_integrator.rb +60 -0
  68. data/lib/dh_easy/core/plugin/executor.rb +19 -0
  69. data/lib/dh_easy/core/plugin/executor_behavior.rb +32 -0
  70. data/lib/dh_easy/core/plugin/finisher.rb +19 -0
  71. data/lib/dh_easy/core/plugin/finisher_behavior.rb +9 -0
  72. data/lib/dh_easy/core/plugin/initialize_hook.rb +17 -0
  73. data/lib/dh_easy/core/plugin/parser.rb +19 -0
  74. data/lib/dh_easy/core/plugin/parser_behavior.rb +17 -0
  75. data/lib/dh_easy/core/plugin/seeder.rb +44 -0
  76. data/lib/dh_easy/core/plugin/seeder_behavior.rb +9 -0
  77. data/lib/dh_easy/core/smart_collection.rb +236 -0
  78. data/lib/dh_easy/core/version.rb +6 -0
  79. metadata +249 -0
@@ -0,0 +1,142 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: DhEasy::Core::Plugin::SeederBehavior
8
+
9
+ &mdash; Documentation by YARD 0.9.20
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../../../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "DhEasy::Core::Plugin::SeederBehavior";
19
+ relpath = '../../../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../../../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../../../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../../../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../../../_index.html">Index (S)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../../../DhEasy.html" title="DhEasy (module)">DhEasy</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../../Core.html" title="DhEasy::Core (module)">Core</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Plugin.html" title="DhEasy::Core::Plugin (module)">Plugin</a></span></span>
41
+ &raquo;
42
+ <span class="title">SeederBehavior</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../../../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: DhEasy::Core::Plugin::SeederBehavior
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+ <dl>
75
+ <dt>Includes:</dt>
76
+ <dd><span class='object_link'><a href="ExecutorBehavior.html" title="DhEasy::Core::Plugin::ExecutorBehavior (module)">ExecutorBehavior</a></span></dd>
77
+ </dl>
78
+
79
+
80
+
81
+
82
+ <dl>
83
+ <dt>Included in:</dt>
84
+ <dd><span class='object_link'><a href="Seeder.html" title="DhEasy::Core::Plugin::Seeder (module)">Seeder</a></span></dd>
85
+ </dl>
86
+
87
+
88
+
89
+ <dl>
90
+ <dt>Defined in:</dt>
91
+ <dd>lib/dh_easy/core/plugin/seeder_behavior.rb</dd>
92
+ </dl>
93
+
94
+ </div>
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+ <h2>Instance Attribute Summary</h2>
103
+
104
+ <h3 class="inherited">Attributes included from <span class='object_link'><a href="ContextIntegrator.html" title="DhEasy::Core::Plugin::ContextIntegrator (module)">ContextIntegrator</a></span></h3>
105
+ <p class="inherited"><span class='object_link'><a href="ContextIntegrator.html#context-instance_method" title="DhEasy::Core::Plugin::ContextIntegrator#context (method)">#context</a></span></p>
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+ <h2>Method Summary</h2>
116
+
117
+ <h3 class="inherited">Methods included from <span class='object_link'><a href="ExecutorBehavior.html" title="DhEasy::Core::Plugin::ExecutorBehavior (module)">ExecutorBehavior</a></span></h3>
118
+ <p class="inherited"><span class='object_link'><a href="ExecutorBehavior.html#enqueue-instance_method" title="DhEasy::Core::Plugin::ExecutorBehavior#enqueue (method)">#enqueue</a></span>, <span class='object_link'><a href="ExecutorBehavior.html#save-instance_method" title="DhEasy::Core::Plugin::ExecutorBehavior#save (method)">#save</a></span></p>
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+ <h3 class="inherited">Methods included from <span class='object_link'><a href="ContextIntegrator.html" title="DhEasy::Core::Plugin::ContextIntegrator (module)">ContextIntegrator</a></span></h3>
129
+ <p class="inherited"><span class='object_link'><a href="ContextIntegrator.html#initialize_hook_core_context_integrator-instance_method" title="DhEasy::Core::Plugin::ContextIntegrator#initialize_hook_core_context_integrator (method)">#initialize_hook_core_context_integrator</a></span>, <span class='object_link'><a href="ContextIntegrator.html#mock_context-instance_method" title="DhEasy::Core::Plugin::ContextIntegrator#mock_context (method)">#mock_context</a></span></p>
130
+
131
+
132
+ </div>
133
+
134
+ <div id="footer">
135
+ Generated on Wed Dec 4 23:00:02 2019 by
136
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
137
+ 0.9.20 (ruby-2.5.3).
138
+ </div>
139
+
140
+ </div>
141
+ </body>
142
+ </html>
@@ -0,0 +1,1087 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Class: DhEasy::Core::SmartCollection
8
+
9
+ &mdash; Documentation by YARD 0.9.20
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "DhEasy::Core::SmartCollection";
19
+ relpath = '../../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../../_index.html">Index (S)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../../DhEasy.html" title="DhEasy (module)">DhEasy</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Core.html" title="DhEasy::Core (module)">Core</a></span></span>
41
+ &raquo;
42
+ <span class="title">SmartCollection</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: DhEasy::Core::SmartCollection
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Array</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">Array</li>
78
+
79
+ <li class="next">DhEasy::Core::SmartCollection</li>
80
+
81
+ </ul>
82
+ <a href="#" class="inheritanceTree">show all</a>
83
+
84
+ </dd>
85
+ </dl>
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+ <dl>
98
+ <dt>Defined in:</dt>
99
+ <dd>lib/dh_easy/core/smart_collection.rb</dd>
100
+ </dl>
101
+
102
+ </div>
103
+
104
+ <h2>Overview</h2><div class="docstring">
105
+ <div class="discussion">
106
+
107
+ <p>Smart collection capable to avoid duplicates on insert by matching id</p>
108
+
109
+ <pre class="code ruby"><code class="ruby">defined fields along events.
110
+ </code></pre>
111
+
112
+
113
+ </div>
114
+ </div>
115
+ <div class="tags">
116
+
117
+
118
+ </div>
119
+
120
+ <h2>
121
+ Constant Summary
122
+ <small><a href="#" class="constants_summary_toggle">collapse</a></small>
123
+ </h2>
124
+
125
+ <dl class="constants">
126
+
127
+ <dt id="EVENTS-constant" class="">EVENTS =
128
+ <div class="docstring">
129
+ <div class="discussion">
130
+
131
+ <p>Implemented event list.</p>
132
+
133
+
134
+ </div>
135
+ </div>
136
+ <div class="tags">
137
+
138
+
139
+ </div>
140
+ </dt>
141
+ <dd><pre class="code"><span class='lbracket'>[</span>
142
+ <span class='symbol'>:before_defaults</span><span class='comma'>,</span>
143
+ <span class='symbol'>:before_match</span><span class='comma'>,</span>
144
+ <span class='symbol'>:before_insert</span><span class='comma'>,</span>
145
+ <span class='symbol'>:after_insert</span>
146
+ <span class='rbracket'>]</span></pre></dd>
147
+
148
+ </dl>
149
+
150
+
151
+
152
+
153
+
154
+ <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
155
+ <ul class="summary">
156
+
157
+ <li class="public ">
158
+ <span class="summary_signature">
159
+
160
+ <a href="#defaults-instance_method" title="#defaults (instance method)">#<strong>defaults</strong> &#x21d2; Object </a>
161
+
162
+
163
+
164
+ </span>
165
+
166
+
167
+
168
+
169
+ <span class="note title readonly">readonly</span>
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+ <span class="summary_desc"><div class='inline'>
180
+ <p>Default fields values.</p>
181
+ </div></span>
182
+
183
+ </li>
184
+
185
+
186
+ <li class="public ">
187
+ <span class="summary_signature">
188
+
189
+ <a href="#key_fields-instance_method" title="#key_fields (instance method)">#<strong>key_fields</strong> &#x21d2; Object </a>
190
+
191
+
192
+
193
+ </span>
194
+
195
+
196
+
197
+
198
+ <span class="note title readonly">readonly</span>
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+ <span class="summary_desc"><div class='inline'>
209
+ <p>Key fields, analog to primary keys.</p>
210
+ </div></span>
211
+
212
+ </li>
213
+
214
+
215
+ </ul>
216
+
217
+
218
+
219
+
220
+
221
+ <h2>
222
+ Instance Method Summary
223
+ <small><a href="#" class="summary_toggle">collapse</a></small>
224
+ </h2>
225
+
226
+ <ul class="summary">
227
+
228
+ <li class="public ">
229
+ <span class="summary_signature">
230
+
231
+ <a href="#<<-instance_method" title="#&lt;&lt; (instance method)">#<strong>&lt;&lt;</strong>(item) &#x21d2; Object </a>
232
+
233
+
234
+
235
+ </span>
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+ <span class="summary_desc"><div class='inline'>
246
+ <p>Add/remplace an item avoiding duplicates.</p>
247
+ </div></span>
248
+
249
+ </li>
250
+
251
+
252
+ <li class="public ">
253
+ <span class="summary_signature">
254
+
255
+ <a href="#bind_event-instance_method" title="#bind_event (instance method)">#<strong>bind_event</strong>(key, &amp;block) &#x21d2; Object </a>
256
+
257
+
258
+
259
+ </span>
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+ <span class="summary_desc"><div class='inline'>
270
+ <p>Add event binding by key and block.</p>
271
+ </div></span>
272
+
273
+ </li>
274
+
275
+
276
+ <li class="public ">
277
+ <span class="summary_signature">
278
+
279
+ <a href="#find_match-instance_method" title="#find_match (instance method)">#<strong>find_match</strong>(filter) &#x21d2; Hash<sup>?</sup> </a>
280
+
281
+
282
+
283
+ </span>
284
+
285
+
286
+
287
+
288
+
289
+
290
+
291
+
292
+
293
+ <span class="summary_desc"><div class='inline'>
294
+ <p>Find an item by matching filter keys.</p>
295
+ </div></span>
296
+
297
+ </li>
298
+
299
+
300
+ <li class="public ">
301
+ <span class="summary_signature">
302
+
303
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(key_fields, opts = {}) &#x21d2; SmartCollection </a>
304
+
305
+
306
+
307
+ </span>
308
+
309
+
310
+ <span class="note title constructor">constructor</span>
311
+
312
+
313
+
314
+
315
+
316
+
317
+
318
+
319
+ <span class="summary_desc"><div class='inline'>
320
+ <p>Initialize collection.</p>
321
+ </div></span>
322
+
323
+ </li>
324
+
325
+
326
+ <li class="public ">
327
+ <span class="summary_signature">
328
+
329
+ <a href="#match_keys%3F-instance_method" title="#match_keys? (instance method)">#<strong>match_keys?</strong>(item_a, item_b) &#x21d2; Boolean </a>
330
+
331
+
332
+
333
+ </span>
334
+
335
+
336
+
337
+
338
+
339
+
340
+
341
+
342
+
343
+ <span class="summary_desc"><div class='inline'>
344
+ <p>Check whenever two items keys match.</p>
345
+ </div></span>
346
+
347
+ </li>
348
+
349
+
350
+ </ul>
351
+
352
+
353
+
354
+ <div id="constructor_details" class="method_details_list">
355
+ <h2>Constructor Details</h2>
356
+
357
+ <div class="method_details first">
358
+ <h3 class="signature first" id="initialize-instance_method">
359
+
360
+ #<strong>initialize</strong>(key_fields, opts = {}) &#x21d2; <tt><span class='object_link'><a href="" title="DhEasy::Core::SmartCollection (class)">SmartCollection</a></span></tt>
361
+
362
+
363
+
364
+
365
+
366
+ </h3><div class="docstring">
367
+ <div class="discussion">
368
+
369
+ <div class="note notetag">
370
+ <strong>Note:</strong>
371
+ <div class='inline'>
372
+ <p>Defaults will apply to missing fields and null values only.</p>
373
+ </div>
374
+ </div>
375
+
376
+
377
+ <p>Initialize collection</p>
378
+
379
+
380
+ </div>
381
+ </div>
382
+ <div class="tags">
383
+
384
+ <div class="examples">
385
+ <p class="tag_title">Examples:</p>
386
+
387
+
388
+ <p class="example_title"><div class='inline'>
389
+ <p>With default values.</p>
390
+ </div></p>
391
+
392
+ <pre class="example code"><code><span class='id identifier rubyid_count'>count</span> <span class='op'>=</span> <span class='int'>0</span>
393
+ <span class='id identifier rubyid_defaults'>defaults</span> <span class='op'>=</span> <span class='lbrace'>{</span>
394
+ <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>id</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_lambda'>lambda</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_item'>item</span><span class='op'>|</span> <span class='id identifier rubyid_count'>count</span> <span class='op'>+=</span> <span class='int'>1</span><span class='rbrace'>}</span><span class='comma'>,</span>
395
+ <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>aaa</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>111</span><span class='comma'>,</span>
396
+ <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>bbb</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_proc'>proc</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_item'>item</span><span class='op'>|</span> <span class='id identifier rubyid_item'>item</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>ccc</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>No ccc</span><span class='tstring_end'>&#39;</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Has ccc</span><span class='tstring_end'>&#39;</span></span><span class='rbrace'>}</span>
397
+ <span class='rbrace'>}</span>
398
+ <span class='id identifier rubyid_values'>values</span> <span class='op'>=</span> <span class='lbracket'>[</span>
399
+ <span class='lbrace'>{</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>aaa</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Defaults apply on nil values only</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>bbb</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='kw'>nil</span><span class='rbrace'>}</span><span class='comma'>,</span>
400
+ <span class='lbrace'>{</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>ccc</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>ddd</span><span class='tstring_end'>&#39;</span></span><span class='rbrace'>}</span><span class='comma'>,</span>
401
+ <span class='lbrace'>{</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>id</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>abc123</span><span class='tstring_end'>&#39;</span></span><span class='rbrace'>}</span>
402
+ <span class='rbracket'>]</span>
403
+ <span class='id identifier rubyid_new_item'>new_item</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>bbb</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Look mom! no ccc</span><span class='tstring_end'>&#39;</span></span><span class='rbrace'>}</span>
404
+ <span class='id identifier rubyid_collection'>collection</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="" title="DhEasy::Core::SmartCollection (class)">SmartCollection</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>id</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>defaults:</span> <span class='id identifier rubyid_defaults'>defaults</span>
405
+ <span class='id identifier rubyid_collection'>collection</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_new_item'>new_item</span>
406
+ <span class='id identifier rubyid_collection'>collection</span>
407
+ <span class='comment'># =&gt; [
408
+ </span><span class='comment'># {&#39;id&#39; =&gt; 1, &#39;aaa&#39; =&gt; &#39;Defaults apply on nil values only&#39;, &#39;bbb&#39; =&gt; &#39;No ccc&#39;},
409
+ </span><span class='comment'># {&#39;id&#39; =&gt; 2, &#39;aaa&#39; =&gt; 111, &#39;bbb&#39; =&gt; &#39;Has ccc&#39;, &#39;ccc&#39; =&gt; &#39;ddd&#39;},
410
+ </span><span class='comment'># {&#39;id&#39; =&gt; &#39;abc123&#39;, &#39;aaa&#39; =&gt; 111, &#39;bbb&#39; =&gt; &#39;No ccc&#39;},
411
+ </span><span class='comment'># {&#39;id&#39; =&gt; 3, &#39;aaa&#39; =&gt; 111, &#39;bbb&#39; =&gt; &#39;Look mom! no ccc&#39;}
412
+ </span><span class='comment'># ]</span></code></pre>
413
+
414
+ </div>
415
+ <p class="tag_title">Parameters:</p>
416
+ <ul class="param">
417
+
418
+ <li>
419
+
420
+ <span class='name'>key_fields</span>
421
+
422
+
423
+ <span class='type'>(<tt>Array</tt>)</span>
424
+
425
+
426
+
427
+ &mdash;
428
+ <div class='inline'>
429
+ <p>Key fields, analog to primary keys.</p>
430
+ </div>
431
+
432
+ </li>
433
+
434
+ <li>
435
+
436
+ <span class='name'>opts</span>
437
+
438
+
439
+ <span class='type'>(<tt>Hash</tt>)</span>
440
+
441
+
442
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
443
+
444
+
445
+ &mdash;
446
+ <div class='inline'>
447
+ <p>({}) Configuration options.</p>
448
+ </div>
449
+
450
+ </li>
451
+
452
+ </ul>
453
+
454
+
455
+
456
+
457
+
458
+
459
+ <p class="tag_title">Options Hash (<tt>opts</tt>):</p>
460
+ <ul class="option">
461
+
462
+ <li>
463
+ <span class="name">:values</span>
464
+ <span class="type">(<tt>Array</tt>)</span>
465
+ <span class="default">
466
+
467
+ &mdash; default:
468
+ <tt>[]</tt>
469
+
470
+ </span>
471
+
472
+ &mdash; <div class='inline'>
473
+ <p>Initial values; will avoid duplicates on insert.</p>
474
+ </div>
475
+
476
+ </li>
477
+
478
+ <li>
479
+ <span class="name">:defaults</span>
480
+ <span class="type">(<tt>Hash</tt>)</span>
481
+ <span class="default">
482
+
483
+ &mdash; default:
484
+ <tt>{}</tt>
485
+
486
+ </span>
487
+
488
+ &mdash; <div class='inline'>
489
+ <p>Default values. `proc` values will be executed to get default value.</p>
490
+ </div>
491
+
492
+ </li>
493
+
494
+ </ul>
495
+
496
+
497
+
498
+ </div><table class="source_code">
499
+ <tr>
500
+ <td>
501
+ <pre class="lines">
502
+
503
+
504
+ 50
505
+ 51
506
+ 52
507
+ 53
508
+ 54
509
+ 55</pre>
510
+ </td>
511
+ <td>
512
+ <pre class="code"><span class="info file"># File 'lib/dh_easy/core/smart_collection.rb', line 50</span>
513
+
514
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span> <span class='id identifier rubyid_key_fields'>key_fields</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
515
+ <span class='ivar'>@key_fields</span> <span class='op'>=</span> <span class='id identifier rubyid_key_fields'>key_fields</span> <span class='op'>||</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
516
+ <span class='ivar'>@defaults</span> <span class='op'>=</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:defaults</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
517
+ <span class='kw'>super</span> <span class='int'>0</span>
518
+ <span class='lparen'>(</span><span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:values</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_item'>item</span><span class='op'>|</span> <span class='kw'>self</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_item'>item</span><span class='rbrace'>}</span>
519
+ <span class='kw'>end</span></pre>
520
+ </td>
521
+ </tr>
522
+ </table>
523
+ </div>
524
+
525
+ </div>
526
+
527
+ <div id="instance_attr_details" class="attr_details">
528
+ <h2>Instance Attribute Details</h2>
529
+
530
+
531
+ <span id=""></span>
532
+ <div class="method_details first">
533
+ <h3 class="signature first" id="defaults-instance_method">
534
+
535
+ #<strong>defaults</strong> &#x21d2; <tt>Object</tt> <span class="extras">(readonly)</span>
536
+
537
+
538
+
539
+
540
+
541
+ </h3><div class="docstring">
542
+ <div class="discussion">
543
+
544
+ <p>Default fields values. Apply to missing fields and null values.</p>
545
+
546
+
547
+ </div>
548
+ </div>
549
+ <div class="tags">
550
+
551
+
552
+ </div><table class="source_code">
553
+ <tr>
554
+ <td>
555
+ <pre class="lines">
556
+
557
+
558
+ 17
559
+ 18
560
+ 19</pre>
561
+ </td>
562
+ <td>
563
+ <pre class="code"><span class="info file"># File 'lib/dh_easy/core/smart_collection.rb', line 17</span>
564
+
565
+ <span class='kw'>def</span> <span class='id identifier rubyid_defaults'>defaults</span>
566
+ <span class='ivar'>@defaults</span>
567
+ <span class='kw'>end</span></pre>
568
+ </td>
569
+ </tr>
570
+ </table>
571
+ </div>
572
+
573
+
574
+ <span id=""></span>
575
+ <div class="method_details ">
576
+ <h3 class="signature " id="key_fields-instance_method">
577
+
578
+ #<strong>key_fields</strong> &#x21d2; <tt>Object</tt> <span class="extras">(readonly)</span>
579
+
580
+
581
+
582
+
583
+
584
+ </h3><div class="docstring">
585
+ <div class="discussion">
586
+
587
+ <p>Key fields, analog to primary keys.</p>
588
+
589
+
590
+ </div>
591
+ </div>
592
+ <div class="tags">
593
+
594
+
595
+ </div><table class="source_code">
596
+ <tr>
597
+ <td>
598
+ <pre class="lines">
599
+
600
+
601
+ 15
602
+ 16
603
+ 17</pre>
604
+ </td>
605
+ <td>
606
+ <pre class="code"><span class="info file"># File 'lib/dh_easy/core/smart_collection.rb', line 15</span>
607
+
608
+ <span class='kw'>def</span> <span class='id identifier rubyid_key_fields'>key_fields</span>
609
+ <span class='ivar'>@key_fields</span>
610
+ <span class='kw'>end</span></pre>
611
+ </td>
612
+ </tr>
613
+ </table>
614
+ </div>
615
+
616
+ </div>
617
+
618
+
619
+ <div id="instance_method_details" class="method_details_list">
620
+ <h2>Instance Method Details</h2>
621
+
622
+
623
+ <div class="method_details first">
624
+ <h3 class="signature first" id="<<-instance_method">
625
+
626
+ #<strong>&lt;&lt;</strong>(item) &#x21d2; <tt>Object</tt>
627
+
628
+
629
+
630
+
631
+
632
+ </h3><div class="docstring">
633
+ <div class="discussion">
634
+
635
+ <p>Add/remplace an item avoiding duplicates</p>
636
+
637
+
638
+ </div>
639
+ </div>
640
+ <div class="tags">
641
+
642
+
643
+ </div><table class="source_code">
644
+ <tr>
645
+ <td>
646
+ <pre class="lines">
647
+
648
+
649
+ 224
650
+ 225
651
+ 226
652
+ 227
653
+ 228
654
+ 229
655
+ 230
656
+ 231
657
+ 232
658
+ 233</pre>
659
+ </td>
660
+ <td>
661
+ <pre class="code"><span class="info file"># File 'lib/dh_easy/core/smart_collection.rb', line 224</span>
662
+
663
+ <span class='kw'>def</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_item'>item</span>
664
+ <span class='id identifier rubyid_item'>item</span> <span class='op'>=</span> <span class='id identifier rubyid_call_event'>call_event</span> <span class='symbol'>:before_defaults</span><span class='comma'>,</span> <span class='id identifier rubyid_item'>item</span><span class='comma'>,</span> <span class='id identifier rubyid_item'>item</span>
665
+ <span class='id identifier rubyid_apply_defaults'>apply_defaults</span> <span class='id identifier rubyid_item'>item</span>
666
+ <span class='id identifier rubyid_item'>item</span> <span class='op'>=</span> <span class='id identifier rubyid_call_event'>call_event</span> <span class='symbol'>:before_match</span><span class='comma'>,</span> <span class='id identifier rubyid_item'>item</span><span class='comma'>,</span> <span class='id identifier rubyid_item'>item</span>
667
+ <span class='id identifier rubyid_match'>match</span> <span class='op'>=</span> <span class='id identifier rubyid_find_match'>find_match</span> <span class='id identifier rubyid_item'>item</span>
668
+ <span class='id identifier rubyid_item'>item</span> <span class='op'>=</span> <span class='id identifier rubyid_call_event'>call_event</span> <span class='symbol'>:before_insert</span><span class='comma'>,</span> <span class='id identifier rubyid_item'>item</span><span class='comma'>,</span> <span class='id identifier rubyid_item'>item</span><span class='comma'>,</span> <span class='id identifier rubyid_match'>match</span>
669
+ <span class='id identifier rubyid_delete'>delete</span> <span class='id identifier rubyid_match'>match</span> <span class='kw'>unless</span> <span class='id identifier rubyid_match'>match</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
670
+ <span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_item'>item</span><span class='rparen'>)</span>
671
+ <span class='id identifier rubyid_call_event'>call_event</span> <span class='symbol'>:after_insert</span><span class='comma'>,</span> <span class='id identifier rubyid_result'>result</span><span class='comma'>,</span> <span class='id identifier rubyid_item'>item</span><span class='comma'>,</span> <span class='id identifier rubyid_match'>match</span>
672
+ <span class='kw'>end</span></pre>
673
+ </td>
674
+ </tr>
675
+ </table>
676
+ </div>
677
+
678
+ <div class="method_details ">
679
+ <h3 class="signature " id="bind_event-instance_method">
680
+
681
+ #<strong>bind_event</strong>(key, &amp;block) &#x21d2; <tt>Object</tt>
682
+
683
+
684
+
685
+
686
+
687
+ </h3><div class="docstring">
688
+ <div class="discussion">
689
+
690
+ <div class="note notetag">
691
+ <strong>Note:</strong>
692
+ <div class='inline'>
693
+ <p>Some events will expect a return value to replace item on insertion:</p>
694
+ <ul><li>
695
+ <p>`before_match`</p>
696
+ </li><li>
697
+ <p>`before_defaults`</p>
698
+ </li><li>
699
+ <p>`before_insert`</p>
700
+ </li></ul>
701
+ </div>
702
+ </div>
703
+
704
+
705
+ <p>Add event binding by key and block.</p>
706
+
707
+
708
+ </div>
709
+ </div>
710
+ <div class="tags">
711
+
712
+ <div class="examples">
713
+ <p class="tag_title">Examples:</p>
714
+
715
+
716
+ <p class="example_title"><div class='inline'>
717
+ <p>before_defaults</p>
718
+ </div></p>
719
+
720
+ <pre class="example code"><code><span class='id identifier rubyid_defaults'>defaults</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>aaa</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>111</span><span class='rbrace'>}</span>
721
+ <span class='id identifier rubyid_collection'>collection</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="" title="DhEasy::Core::SmartCollection (class)">SmartCollection</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="DhEasy::Core::SmartCollection#initialize (method)">new</a></span></span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span>
722
+ <span class='label'>defaults:</span> <span class='id identifier rubyid_defaults'>defaults</span>
723
+ <span class='id identifier rubyid_collection'>collection</span><span class='period'>.</span><span class='id identifier rubyid_bind_event'>bind_event</span><span class='lparen'>(</span><span class='symbol'>:before_defaults</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_collection'>collection</span><span class='comma'>,</span> <span class='id identifier rubyid_item'>item</span><span class='op'>|</span>
724
+ <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_collection'>collection</span>
725
+ <span class='comment'># =&gt; []
726
+ </span> <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_item'>item</span>
727
+ <span class='comment'># =&gt; {&#39;bbb&#39; =&gt; 222}
728
+ </span>
729
+ <span class='comment'># Sending the item back is required, or a new one
730
+ </span> <span class='comment'># in case you want to replace item to insert.
731
+ </span> <span class='id identifier rubyid_item'>item</span>
732
+ <span class='kw'>end</span>
733
+ <span class='id identifier rubyid_data'>data</span> <span class='op'>&lt;&lt;</span> <span class='lbrace'>{</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>bbb</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>222</span><span class='rbrace'>}</span>
734
+ <span class='id identifier rubyid_data'>data</span>
735
+ <span class='comment'># =&gt; [{&#39;aaa&#39; =&gt; 111, &#39;bbb&#39; =&gt; 222}]</span></code></pre>
736
+
737
+
738
+ <p class="example_title"><div class='inline'>
739
+ <p>before_match</p>
740
+ </div></p>
741
+
742
+ <pre class="example code"><code>keys = [&#39;id&#39;]
743
+ defaults = {&#39;aaa&#39; =&gt; 111}
744
+ values = [
745
+ {&#39;id&#39; =&gt; 1, &#39;ccc&#39; =&gt; 333}
746
+ ]
747
+ collection = SmartCollection.new keys,
748
+ defaults: defaults
749
+ values: values
750
+ collection.bind_event(:before_match) do |collection, item|
751
+ puts collection
752
+ # =&gt; [{&#39;id&#39; =&gt; 1, &#39;aaa&#39; =&gt; 111, &#39;ccc&#39; =&gt; 333}]
753
+ puts item
754
+ # =&gt; {&#39;id&#39; =&gt; 1, &#39;aaa&#39; =&gt; 111, &#39;bbb&#39; =&gt; 222}
755
+
756
+ # Sending the item back is required, or a new one
757
+ # in case you want to replace item to insert.
758
+ item
759
+ end
760
+ data &lt;&lt; {&#39;id&#39; =&gt; 1, &#39;bbb&#39; =&gt; 222}
761
+ data
762
+ # =&gt; [{&#39;id&#39; =&gt; 1, &#39;aaa&#39; =&gt; 111, &#39;bbb&#39; =&gt; 222}]</code></pre>
763
+
764
+
765
+ <p class="example_title"><div class='inline'>
766
+ <p>before_insert</p>
767
+ </div></p>
768
+
769
+ <pre class="example code"><code>keys = [&#39;id&#39;]
770
+ defaults = {&#39;aaa&#39; =&gt; 111}
771
+ values = [
772
+ {&#39;id&#39; =&gt; 1, &#39;ccc&#39; =&gt; 333}
773
+ ]
774
+ collection = SmartCollection.new keys,
775
+ defaults: defaults
776
+ values: values
777
+ collection.bind_event(:before_insert) do |collection, item, match|
778
+ puts collection
779
+ # =&gt; [{&#39;id&#39; =&gt; 1, &#39;aaa&#39; =&gt; 111, &#39;ccc&#39; =&gt; 333}]
780
+ puts item
781
+ # =&gt; {&#39;id&#39; =&gt; 1, &#39;aaa&#39; =&gt; 111, &#39;bbb&#39; =&gt; 222}
782
+ puts match
783
+ # =&gt; {&#39;id&#39; =&gt; 1, &#39;aaa&#39; =&gt; 111, &#39;ccc&#39; =&gt; 333}
784
+
785
+ # Sending the item back is required, or a new one
786
+ # in case you want to replace item to insert.
787
+ item
788
+ end
789
+ data &lt;&lt; {&#39;id&#39; =&gt; 1, &#39;bbb&#39; =&gt; 222}
790
+ data
791
+ # =&gt; [{&#39;id&#39; =&gt; 1, &#39;aaa&#39; =&gt; 111, &#39;bbb&#39; =&gt; 222}]</code></pre>
792
+
793
+
794
+ <p class="example_title"><div class='inline'>
795
+ <p>after_insert</p>
796
+ </div></p>
797
+
798
+ <pre class="example code"><code>keys = [&#39;id&#39;]
799
+ defaults = {&#39;aaa&#39; =&gt; 111}
800
+ values = [
801
+ {&#39;id&#39; =&gt; 1, &#39;ccc&#39; =&gt; 333}
802
+ ]
803
+ collection = SmartCollection.new keys,
804
+ defaults: defaults
805
+ values: values
806
+ collection.bind_event(:after_insert) do |collection, item, match|
807
+ puts collection
808
+ # =&gt; [{&#39;id&#39; =&gt; 1, &#39;aaa&#39; =&gt; 111, &#39;bbb&#39; =&gt; 222}]
809
+ puts item
810
+ # =&gt; {&#39;id&#39; =&gt; 1, &#39;aaa&#39; =&gt; 111, &#39;bbb&#39; =&gt; 222}
811
+ puts match
812
+ # =&gt; {&#39;id&#39; =&gt; 1, &#39;aaa&#39; =&gt; 111, &#39;ccc&#39; =&gt; 333}
813
+ # No need to send item back since it is already inserted
814
+ end
815
+ data &lt;&lt; {&#39;id&#39; =&gt; 1, &#39;bbb&#39; =&gt; 222}
816
+ data
817
+ # =&gt; [{&#39;id&#39; =&gt; 1, &#39;aaa&#39; =&gt; 111, &#39;bbb&#39; =&gt; 222}]</code></pre>
818
+
819
+ </div>
820
+ <p class="tag_title">Parameters:</p>
821
+ <ul class="param">
822
+
823
+ <li>
824
+
825
+ <span class='name'>key</span>
826
+
827
+
828
+ <span class='type'>(<tt>Symbol</tt>)</span>
829
+
830
+
831
+
832
+ &mdash;
833
+ <div class='inline'>
834
+ <p>Event name.</p>
835
+ </div>
836
+
837
+ </li>
838
+
839
+ </ul>
840
+
841
+ <p class="tag_title">Raises:</p>
842
+ <ul class="raise">
843
+
844
+ <li>
845
+
846
+
847
+ <span class='type'>(<tt>ArgumentError</tt>)</span>
848
+
849
+
850
+
851
+ &mdash;
852
+ <div class='inline'>
853
+ <p>When unknown event key.</p>
854
+ </div>
855
+
856
+ </li>
857
+
858
+ </ul>
859
+
860
+ </div><table class="source_code">
861
+ <tr>
862
+ <td>
863
+ <pre class="lines">
864
+
865
+
866
+ 161
867
+ 162
868
+ 163
869
+ 164
870
+ 165
871
+ 166</pre>
872
+ </td>
873
+ <td>
874
+ <pre class="code"><span class="info file"># File 'lib/dh_easy/core/smart_collection.rb', line 161</span>
875
+
876
+ <span class='kw'>def</span> <span class='id identifier rubyid_bind_event'>bind_event</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span>
877
+ <span class='kw'>unless</span> <span class='const'><span class='object_link'><a href="#EVENTS-constant" title="DhEasy::Core::SmartCollection::EVENTS (constant)">EVENTS</a></span></span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_key'>key</span>
878
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Unknown event &#39;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>&#39;</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
879
+ <span class='kw'>end</span>
880
+ <span class='lparen'>(</span><span class='id identifier rubyid_events'>events</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_block'>block</span>
881
+ <span class='kw'>end</span></pre>
882
+ </td>
883
+ </tr>
884
+ </table>
885
+ </div>
886
+
887
+ <div class="method_details ">
888
+ <h3 class="signature " id="find_match-instance_method">
889
+
890
+ #<strong>find_match</strong>(filter) &#x21d2; <tt>Hash</tt><sup>?</sup>
891
+
892
+
893
+
894
+
895
+
896
+ </h3><div class="docstring">
897
+ <div class="discussion">
898
+
899
+ <div class="note notetag">
900
+ <strong>Note:</strong>
901
+ <div class='inline'>
902
+ <p><em>Warning:</em> It uses table scan to filter and will be slow.</p>
903
+ </div>
904
+ </div>
905
+
906
+
907
+ <p>Find an item by matching filter keys</p>
908
+
909
+
910
+ </div>
911
+ </div>
912
+ <div class="tags">
913
+ <p class="tag_title">Parameters:</p>
914
+ <ul class="param">
915
+
916
+ <li>
917
+
918
+ <span class='name'>filter</span>
919
+
920
+
921
+ <span class='type'>(<tt>Hash</tt>)</span>
922
+
923
+
924
+
925
+ </li>
926
+
927
+ </ul>
928
+
929
+ <p class="tag_title">Returns:</p>
930
+ <ul class="return">
931
+
932
+ <li>
933
+
934
+
935
+ <span class='type'>(<tt>Hash</tt>, <tt>nil</tt>)</span>
936
+
937
+
938
+
939
+ &mdash;
940
+ <div class='inline'>
941
+ <p>First existing item match or nil when no match.</p>
942
+ </div>
943
+
944
+ </li>
945
+
946
+ </ul>
947
+
948
+ </div><table class="source_code">
949
+ <tr>
950
+ <td>
951
+ <pre class="lines">
952
+
953
+
954
+ 217
955
+ 218
956
+ 219
957
+ 220
958
+ 221</pre>
959
+ </td>
960
+ <td>
961
+ <pre class="code"><span class="info file"># File 'lib/dh_easy/core/smart_collection.rb', line 217</span>
962
+
963
+ <span class='kw'>def</span> <span class='id identifier rubyid_find_match'>find_match</span> <span class='id identifier rubyid_filter'>filter</span>
964
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_item'>item</span><span class='op'>|</span>
965
+ <span class='id identifier rubyid_match_keys?'>match_keys?</span> <span class='id identifier rubyid_item'>item</span><span class='comma'>,</span> <span class='id identifier rubyid_filter'>filter</span>
966
+ <span class='kw'>end</span>
967
+ <span class='kw'>end</span></pre>
968
+ </td>
969
+ </tr>
970
+ </table>
971
+ </div>
972
+
973
+ <div class="method_details ">
974
+ <h3 class="signature " id="match_keys?-instance_method">
975
+
976
+ #<strong>match_keys?</strong>(item_a, item_b) &#x21d2; <tt>Boolean</tt>
977
+
978
+
979
+
980
+
981
+
982
+ </h3><div class="docstring">
983
+ <div class="discussion">
984
+
985
+ <p>Check whenever two items keys match.</p>
986
+
987
+
988
+ </div>
989
+ </div>
990
+ <div class="tags">
991
+ <p class="tag_title">Parameters:</p>
992
+ <ul class="param">
993
+
994
+ <li>
995
+
996
+ <span class='name'>item_a</span>
997
+
998
+
999
+ <span class='type'>(<tt>Hash</tt>)</span>
1000
+
1001
+
1002
+
1003
+ &mdash;
1004
+ <div class='inline'>
1005
+ <p>Item to match.</p>
1006
+ </div>
1007
+
1008
+ </li>
1009
+
1010
+ <li>
1011
+
1012
+ <span class='name'>item_b</span>
1013
+
1014
+
1015
+ <span class='type'>(<tt>Hash</tt>)</span>
1016
+
1017
+
1018
+
1019
+ &mdash;
1020
+ <div class='inline'>
1021
+ <p>Item to match.</p>
1022
+ </div>
1023
+
1024
+ </li>
1025
+
1026
+ </ul>
1027
+
1028
+ <p class="tag_title">Returns:</p>
1029
+ <ul class="return">
1030
+
1031
+ <li>
1032
+
1033
+
1034
+ <span class='type'>(<tt>Boolean</tt>)</span>
1035
+
1036
+
1037
+
1038
+ </li>
1039
+
1040
+ </ul>
1041
+
1042
+ </div><table class="source_code">
1043
+ <tr>
1044
+ <td>
1045
+ <pre class="lines">
1046
+
1047
+
1048
+ 187
1049
+ 188
1050
+ 189
1051
+ 190
1052
+ 191
1053
+ 192
1054
+ 193
1055
+ 194
1056
+ 195</pre>
1057
+ </td>
1058
+ <td>
1059
+ <pre class="code"><span class="info file"># File 'lib/dh_easy/core/smart_collection.rb', line 187</span>
1060
+
1061
+ <span class='kw'>def</span> <span class='id identifier rubyid_match_keys?'>match_keys?</span> <span class='id identifier rubyid_item_a'>item_a</span><span class='comma'>,</span> <span class='id identifier rubyid_item_b'>item_b</span>
1062
+ <span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>if</span> <span class='id identifier rubyid_key_fields'>key_fields</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>||</span> <span class='id identifier rubyid_key_fields'>key_fields</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span> <span class='op'>&lt;</span> <span class='int'>1</span>
1063
+ <span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='id identifier rubyid_item_a'>item_a</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_item_b'>item_b</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
1064
+ <span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>if</span> <span class='id identifier rubyid_item_a'>item_a</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>||</span> <span class='id identifier rubyid_item_b'>item_b</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
1065
+ <span class='id identifier rubyid_key_fields'>key_fields</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='op'>|</span>
1066
+ <span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>if</span> <span class='id identifier rubyid_item_a'>item_a</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>!=</span> <span class='id identifier rubyid_item_b'>item_b</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span>
1067
+ <span class='kw'>end</span>
1068
+ <span class='kw'>true</span>
1069
+ <span class='kw'>end</span></pre>
1070
+ </td>
1071
+ </tr>
1072
+ </table>
1073
+ </div>
1074
+
1075
+ </div>
1076
+
1077
+ </div>
1078
+
1079
+ <div id="footer">
1080
+ Generated on Wed Dec 4 23:00:03 2019 by
1081
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1082
+ 0.9.20 (ruby-2.5.3).
1083
+ </div>
1084
+
1085
+ </div>
1086
+ </body>
1087
+ </html>