eitil 1.0.1.e.2 → 1.0.3.e.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +0 -1
- data/eitil_core/README.md +344 -0
- data/eitil_core/lib/eitil_core.rb +24 -0
- data/eitil_core/lib/eitil_core/application_controller.rb +2 -0
- data/eitil_core/lib/eitil_core/application_controller/slice_params.rb +14 -0
- data/eitil_core/lib/eitil_core/application_record.rb +4 -0
- data/eitil_core/lib/eitil_core/application_record/all_associations.rb +16 -0
- data/eitil_core/lib/eitil_core/application_record/find_by_like.rb +15 -0
- data/eitil_core/lib/eitil_core/application_record/where_like.rb +15 -0
- data/eitil_core/lib/eitil_core/argument_helpers.rb +13 -0
- data/eitil_core/lib/eitil_core/argument_helpers/all_args_to_ivars.rb +12 -0
- data/eitil_core/lib/eitil_core/argument_helpers/all_args_to_ivars_bang.rb +15 -0
- data/eitil_core/lib/eitil_core/argument_helpers/all_kwargs_to_ivars.rb +12 -0
- data/eitil_core/lib/eitil_core/argument_helpers/all_kwargs_to_ivars_bang.rb +15 -0
- data/eitil_core/lib/eitil_core/argument_helpers/args_to_h.rb +15 -0
- data/eitil_core/lib/eitil_core/argument_helpers/args_to_h_bang.rb +17 -0
- data/eitil_core/lib/eitil_core/argument_helpers/args_to_ivars.rb +12 -0
- data/eitil_core/lib/eitil_core/argument_helpers/args_to_ivars_bang.rb +15 -0
- data/eitil_core/lib/eitil_core/concerns.rb +2 -0
- data/eitil_core/lib/eitil_core/concerns/include_concerns_of.rb +15 -0
- data/eitil_core/lib/eitil_core/datetime.rb +2 -0
- data/eitil_core/lib/eitil_core/datetime/prettify.rb +10 -0
- data/eitil_core/lib/eitil_core/errors.rb +2 -0
- data/eitil_core/lib/eitil_core/errors/raise_error.rb +11 -0
- data/eitil_core/lib/eitil_core/float.rb +2 -0
- data/eitil_core/lib/eitil_core/float/safe_to_i.rb +12 -0
- data/eitil_core/lib/eitil_core/hash.rb +2 -0
- data/eitil_core/lib/eitil_core/hash/auto_dig.rb +17 -0
- data/eitil_core/lib/eitil_core/lookups.rb +3 -0
- data/eitil_core/lib/eitil_core/lookups/all_methods.rb +32 -0
- data/eitil_core/lib/eitil_core/lookups/gem_path.rb +10 -0
- data/eitil_core/lib/eitil_core/railtie.rb +37 -0
- data/eitil_core/lib/eitil_core/safe_executions.rb +3 -0
- data/eitil_core/lib/eitil_core/safe_executions/safe_call.rb +12 -0
- data/eitil_core/lib/eitil_core/safe_executions/safe_send.rb +12 -0
- data/eitil_core/lib/eitil_core/setters.rb +2 -0
- data/eitil_core/lib/eitil_core/setters/set_ivars.rb +12 -0
- data/eitil_core/lib/eitil_core/type_checkers.rb +2 -0
- data/eitil_core/lib/eitil_core/type_checkers/is_num_or_nan.rb +96 -0
- data/eitil_core/lib/eitil_core/validations.rb +2 -0
- data/eitil_core/lib/eitil_core/validations/run_validations.rb +10 -0
- data/eitil_integrate/README.md +19 -0
- data/eitil_integrate/lib/eitil_integrate.rb +4 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter.rb +22 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum.rb +10 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/drop_data.rb +54 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/format_data.rb +27 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/initialize.rb +22 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/present_data.rb +31 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/reduce_data.rb +18 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/sum_data.rb +56 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/default_export.rb +43 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb +50 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/infos.rb +20 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/initialize.rb +28 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/lookups.rb +40 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/selectors.rb +58 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/setters.rb +27 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/store_file.rb +34 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/style_cells.rb +97 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/validations.rb +28 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/write_cells.rb +78 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/write_messages.rb +18 -0
- data/eitil_integrate/lib/eitil_integrate/railtie.rb +10 -0
- data/eitil_store/README.md +16 -0
- data/eitil_store/lib/eitil_store.rb +4 -0
- data/eitil_store/lib/eitil_store/railtie.rb +10 -0
- data/eitil_store/lib/eitil_store/regex.rb +4 -0
- data/eitil_store/lib/eitil_store/regex/regex.rb +41 -0
- data/eitil_support/README.md +78 -0
- data/eitil_support/lib/eitil_support.rb +5 -0
- data/eitil_support/lib/eitil_support/directory.rb +2 -0
- data/eitil_support/lib/eitil_support/directory/lookups.rb +26 -0
- data/eitil_support/lib/eitil_support/railtie.rb +10 -0
- data/eitil_support/lib/eitil_support/stacktrace.rb +4 -0
- data/eitil_support/lib/eitil_support/stacktrace/audit.rb +15 -0
- data/eitil_support/lib/eitil_support/stacktrace/call.rb +17 -0
- data/eitil_support/lib/eitil_support/stacktrace/stack.rb +28 -0
- data/eitil_wrapper/README.md +181 -0
- data/eitil_wrapper/lib/eitil_wrapper.rb +7 -0
- data/eitil_wrapper/lib/eitil_wrapper/decorators.rb +3 -0
- data/eitil_wrapper/lib/eitil_wrapper/decorators/application_decorator.rb +19 -0
- data/eitil_wrapper/lib/eitil_wrapper/decorators/controller_decorator.rb +60 -0
- data/eitil_wrapper/lib/eitil_wrapper/jobs.rb +4 -0
- data/eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb +34 -0
- data/eitil_wrapper/lib/eitil_wrapper/jobs/new_job_debugger.rb +37 -0
- data/eitil_wrapper/lib/eitil_wrapper/jobs/single_method_job.rb +8 -0
- data/eitil_wrapper/lib/eitil_wrapper/railtie.rb +49 -0
- data/eitil_wrapper/lib/eitil_wrapper/routes.rb +2 -0
- data/eitil_wrapper/lib/eitil_wrapper/routes/extended_resources.rb +40 -0
- data/eitil_wrapper/lib/eitil_wrapper/scopes.rb +2 -0
- data/eitil_wrapper/lib/eitil_wrapper/scopes/default_scopes.rb +80 -0
- data/lib/eitil.rb +5 -0
- data/lib/eitil/all.rb +17 -0
- data/lib/eitil/railtie.rb +37 -0
- data/lib/eitil/version.rb +5 -0
- metadata +125 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1872b8eec9fde6e3cc707f5d66eb6c595000b3d4bb1d57d100b5759b39167cc2
|
4
|
+
data.tar.gz: d4cc20f05567ae72bfd693efe75e559584308a16fdf3322f6de6f2bd13ab448d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 747044b67ccab759ecd85c6e58e03607fff0038bfe98aad4f66e6fa8680fd06ac4fbc59922339c4f25ff7e38bdd7dac6feccb00bc0abb806626c1ccdb1a54300
|
7
|
+
data.tar.gz: 165cb9650bbfe9639da5ac493d01ea728001df63515854a5483149a9ff182a0f40796385ec089bf39e72cfb844423d0fa06d94cf1e52e4d0b5addec33f102b64
|
data/Rakefile
CHANGED
@@ -0,0 +1,344 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
# EitilCore
|
5
|
+
|
6
|
+
EitilCore extends the core classes of Ruby and Rails.
|
7
|
+
|
8
|
+
|
9
|
+
## ApplicationController
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
|
13
|
+
require "eitil_core/application_controller"
|
14
|
+
|
15
|
+
```
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
# require "eitil_core/application_controller/slice_params"
|
19
|
+
|
20
|
+
slice_params(*args)
|
21
|
+
# slices request params, converts them to JSON and symbolizes the keys
|
22
|
+
# call as: slice_params :id, :user
|
23
|
+
# => { id: 1, user: 69 }
|
24
|
+
```
|
25
|
+
|
26
|
+
|
27
|
+
## ApplicationRecord
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
|
31
|
+
require "eitil_core/application_controller"
|
32
|
+
|
33
|
+
```
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
# require "eitil_core/application_record/find_by_like"
|
37
|
+
|
38
|
+
self.find_by_like(_hash)
|
39
|
+
# runs .find_by with your string field made into a wildcard and case insensitive
|
40
|
+
# call as: User.find_by_like(name: 'jurriaan')
|
41
|
+
```
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
# require "eitil_core/application_record/where_like"
|
45
|
+
|
46
|
+
self.where_like(_hash)
|
47
|
+
# runs .where with your string field made into a wildcard and case insensitive
|
48
|
+
# call as: User.where_like(name: 'jurriaan')
|
49
|
+
```
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
# require "eitil_core/application_record/all_associations"
|
53
|
+
|
54
|
+
self.all_associations
|
55
|
+
# returns all associations for a given model
|
56
|
+
# call as: Environment.all_associations
|
57
|
+
```
|
58
|
+
|
59
|
+
|
60
|
+
## ArgumentHelpers
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
|
64
|
+
require "eitil_core/arugment_helpers"
|
65
|
+
|
66
|
+
```
|
67
|
+
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
# require "eitil_core/argument_helpers/all_args_to_ivars"
|
71
|
+
|
72
|
+
all_args_to_ivars(binding)
|
73
|
+
# sets all keywords arguments of the method's local binding to instance variables
|
74
|
+
# call as: all_args_to_ivars binding
|
75
|
+
```
|
76
|
+
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
# require "eitil_core/argument_helpers/all_args_to_ivars_bang"
|
80
|
+
|
81
|
+
all_args_to_ivars!
|
82
|
+
# works the same as .all_args_to_ivars, except that passing the binding is no longer required
|
83
|
+
# production usage is discouraged by the creator of the supporting gem
|
84
|
+
```
|
85
|
+
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
# require "eitil_core/argument_helpers/all_kwargs_to_ivars"
|
89
|
+
|
90
|
+
all_kwargs_to_ivars(local_binding, namespace= :kwargs)
|
91
|
+
# sets the method's **kwargs argument to instance variables, with each key as the ivar's "@#{name}" and the value as its value
|
92
|
+
# call as: kwargs_to_ivars binding
|
93
|
+
# the keywords container name can be overwritten, e.g. the common :attributes
|
94
|
+
```
|
95
|
+
|
96
|
+
|
97
|
+
```ruby
|
98
|
+
# require "eitil_core/argument_helpers/all_kwargs_to_ivars_bang"
|
99
|
+
|
100
|
+
all_kwargs_to_ivars!(namespace= :kwargs)
|
101
|
+
# works the same as .all_kwargs_to_ivars, except that passing the binding is no longer required
|
102
|
+
# production usage is discouraged by the creator of the supporting gem
|
103
|
+
```
|
104
|
+
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
# require "eitil_core/argument_helpers/args_to_h"
|
108
|
+
|
109
|
+
args_to_h(binding, *local_vars)
|
110
|
+
# creates a hash, with a given local_var as keys and its value as value
|
111
|
+
# call as: args_to_h(binding, :username, :password)
|
112
|
+
# => { username: 'jurriaan', password: 'matz_is_nice' }
|
113
|
+
```
|
114
|
+
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
# require "eitil_core/argument_helpers/args_to_h_bang"
|
118
|
+
|
119
|
+
args_to_h!(*local_vars)
|
120
|
+
# works the same as .args_to_h, except that passing the binding is no longer required
|
121
|
+
# production usage is discouraged by the creator of the supporting gem
|
122
|
+
```
|
123
|
+
|
124
|
+
|
125
|
+
```ruby
|
126
|
+
# require "eitil_core/argument_helpers/args_to_ivars"
|
127
|
+
|
128
|
+
args_to_ivars(binding, *local_vars)
|
129
|
+
# sets specified keywords arguments of the method's local binding to instance variables
|
130
|
+
# call as: all_args_to_ivars binding :user_id, :user_name
|
131
|
+
```
|
132
|
+
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
# require "eitil_core/argument_helpers/args_to_ivars_bang"
|
136
|
+
|
137
|
+
args_to_ivars!(*local_vars)
|
138
|
+
# works the same as .args_to_ivars, except that passing the binding is no longer required
|
139
|
+
# production usage is discouraged by the creator of the supporting gem
|
140
|
+
```
|
141
|
+
|
142
|
+
|
143
|
+
## Concerns
|
144
|
+
|
145
|
+
```ruby
|
146
|
+
|
147
|
+
require "eitil_core/concerns"
|
148
|
+
|
149
|
+
```
|
150
|
+
|
151
|
+
```ruby
|
152
|
+
# require "eitil_core/concerns/include_concerns_of"
|
153
|
+
|
154
|
+
include_concerns_of(*directories, namespace: nil)
|
155
|
+
# includes models/concerns/{directories}/* if no namespace if given, or all concerns within the given namespace
|
156
|
+
# call as: include_concerns_of :user, :mail
|
157
|
+
# => includes all modules of models/concerns/user/* and models/oncerns/mail/*
|
158
|
+
# or call as: include_concerns_of :request_service, namespace: Eivid::Concerns
|
159
|
+
# tip: call Class.included_modules to view all included modules
|
160
|
+
```
|
161
|
+
|
162
|
+
|
163
|
+
## DateTime
|
164
|
+
|
165
|
+
```ruby
|
166
|
+
|
167
|
+
require "eitil_core/datetime"
|
168
|
+
|
169
|
+
```
|
170
|
+
|
171
|
+
```ruby
|
172
|
+
# require "eitil_core/datetime/prettify"
|
173
|
+
|
174
|
+
prettify
|
175
|
+
# formats DateTime instances into a pretty, simple and filename friendly format
|
176
|
+
# call as: DateTime.now.prettify
|
177
|
+
# => "2021-04-21.17:51:42"
|
178
|
+
```
|
179
|
+
|
180
|
+
|
181
|
+
## Errors
|
182
|
+
|
183
|
+
```ruby
|
184
|
+
|
185
|
+
require "eitil_core/errors"
|
186
|
+
|
187
|
+
```
|
188
|
+
|
189
|
+
```ruby
|
190
|
+
# require "eitil_core/errors/raise_error"
|
191
|
+
|
192
|
+
raise_error(_class_name, message = nil)
|
193
|
+
# creates an error class if currently undefined, inheriting from StandardError, and raises the error with the given message
|
194
|
+
# call as: raise_error "SomethingWentWrongError", "check your code, bro!"
|
195
|
+
# => SomethingWentWrongError (check your code, bro!)
|
196
|
+
```
|
197
|
+
|
198
|
+
|
199
|
+
## Float
|
200
|
+
|
201
|
+
```ruby
|
202
|
+
|
203
|
+
require "eitil_core/float"
|
204
|
+
|
205
|
+
```
|
206
|
+
|
207
|
+
```ruby
|
208
|
+
# require "eitil_core/float/safe_to_i"
|
209
|
+
|
210
|
+
safe_to_i
|
211
|
+
# converts a float to an integer, only when no decimal values are lost.
|
212
|
+
# 8.00.safe_to_i returns 8 (Integer)
|
213
|
+
# 8.88.safe_to_i returns 8.88 (Float)
|
214
|
+
```
|
215
|
+
|
216
|
+
|
217
|
+
## Hash
|
218
|
+
|
219
|
+
```ruby
|
220
|
+
|
221
|
+
require "eitil_core/hash"
|
222
|
+
|
223
|
+
```
|
224
|
+
|
225
|
+
```ruby
|
226
|
+
# require "eitil_core/hash/auto_dig"
|
227
|
+
|
228
|
+
auto_dig(_hash = self, _key)
|
229
|
+
# finds the value for the given hash key, irregardless of the amount of nested layers
|
230
|
+
# call as: {a: 1, b: {c: 2, d: {e: 3}}}.auto_dig :e
|
231
|
+
# => 3
|
232
|
+
```
|
233
|
+
|
234
|
+
|
235
|
+
## Lookups
|
236
|
+
|
237
|
+
```ruby
|
238
|
+
|
239
|
+
require "eitil_core/lookups"
|
240
|
+
|
241
|
+
```
|
242
|
+
|
243
|
+
```ruby
|
244
|
+
# require "eitil_core/lookups/all_methods"
|
245
|
+
|
246
|
+
all_methods(include_ancestors = true, grep: nil)
|
247
|
+
# pretty prints all methods for any object, grouped per type (e.g. private_methods, public_instance_methods)
|
248
|
+
# call as: Class.all_methods false, grep: /json/
|
249
|
+
```
|
250
|
+
|
251
|
+
|
252
|
+
```ruby
|
253
|
+
# require "eitil_core/lookups/gem_path"
|
254
|
+
|
255
|
+
Find.gem_path(gem_name)
|
256
|
+
# finds the root of an installed gem, allowing you to traverse its paths from there.
|
257
|
+
# call as: Find.gem_path("rails")
|
258
|
+
# => "/Users/jurriaanschrofer/.rvm/gems/ruby-2.6.5/gems/rails-5.2.3"
|
259
|
+
```
|
260
|
+
|
261
|
+
|
262
|
+
## SafeExecutions
|
263
|
+
|
264
|
+
```ruby
|
265
|
+
|
266
|
+
require "eitil_core/safe_executions"
|
267
|
+
|
268
|
+
```
|
269
|
+
|
270
|
+
```ruby
|
271
|
+
# require "eitil_core/safe_executions/safe_send"
|
272
|
+
|
273
|
+
safe_send(method, *args, return_value: nil)
|
274
|
+
# a safe version of .send, which in case of an error rescues and returns return_value (default: nil) instead
|
275
|
+
```
|
276
|
+
|
277
|
+
```ruby
|
278
|
+
# require "eitil_core/safe_executions/safe_call"
|
279
|
+
|
280
|
+
safe_call(*args, return_value: nil, &block)
|
281
|
+
# a safe version of .call, which in case of an error rescues and returns return_value (default: nil) instead
|
282
|
+
# accepts either a proc argument or a block
|
283
|
+
```
|
284
|
+
|
285
|
+
|
286
|
+
## Setters
|
287
|
+
|
288
|
+
```ruby
|
289
|
+
|
290
|
+
require "eitil_core/setters"
|
291
|
+
|
292
|
+
```
|
293
|
+
|
294
|
+
```ruby
|
295
|
+
# require "eitil_core/setters/set_ivars"
|
296
|
+
|
297
|
+
set_ivars(*ivars)
|
298
|
+
# sets instance variables named @"#{ivar}" for each symbol passed, by invoking send("set_#{ivar}")
|
299
|
+
# e.g. set_ivars(:user) sets @user with the value returned by your local method .set_user
|
300
|
+
# call as: set_ivars :user, :authentication, :connection
|
301
|
+
```
|
302
|
+
|
303
|
+
|
304
|
+
## TypeCheckers
|
305
|
+
|
306
|
+
```ruby
|
307
|
+
|
308
|
+
require "eitil_core/type_checkers"
|
309
|
+
|
310
|
+
```
|
311
|
+
|
312
|
+
```ruby
|
313
|
+
# require "eitil_core/type_checkers/is_num_or_nan"
|
314
|
+
|
315
|
+
is_num?
|
316
|
+
# returns true if a string matches the Rubinius source code regex for strings and integers, false otherwise
|
317
|
+
# comes in handy since ruby plays it safe on string to number conversion ('aaa'.to_f returns 0.0, thus is valid)
|
318
|
+
# this method is also implemented for all other classes, such as Integer, Float, NilClass, TrueClass, Hash and so on...
|
319
|
+
|
320
|
+
is_nan?
|
321
|
+
# returns true if a string does NOT match the Rubinius source code regex for strings and integers, false otherwise
|
322
|
+
# comes in handy since ruby plays it safe on string to number conversion ('aaa'.to_f returns 0.0, thus is valid)
|
323
|
+
# this method is also implemented for all other classes, such as Integer, Float, NilClass, TrueClass, Hash and so on...
|
324
|
+
```
|
325
|
+
|
326
|
+
|
327
|
+
## Validations
|
328
|
+
|
329
|
+
```ruby
|
330
|
+
|
331
|
+
require "eitil_core/validations"
|
332
|
+
|
333
|
+
```
|
334
|
+
|
335
|
+
```ruby
|
336
|
+
# require "eitil_core/validations/run_validations"
|
337
|
+
|
338
|
+
run_validations(*validations)
|
339
|
+
# calls a method for each argument, namespaced as "validate_#{argument}"
|
340
|
+
# call as: run_validations(:single_receipt, :single_order)
|
341
|
+
# => calls #validate_single_receipt and #validate_single_order
|
342
|
+
```
|
343
|
+
|
344
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
# require "eitil_core"
|
3
|
+
|
4
|
+
# core class patches
|
5
|
+
require "eitil_core/hash"
|
6
|
+
require "eitil_core/float"
|
7
|
+
require "eitil_core/datetime"
|
8
|
+
|
9
|
+
# multi class patches
|
10
|
+
require "eitil_core/type_checkers"
|
11
|
+
|
12
|
+
# rails class patches
|
13
|
+
require "eitil_core/application_record"
|
14
|
+
require "eitil_core/application_controller"
|
15
|
+
|
16
|
+
# helper patches
|
17
|
+
require "eitil_core/errors"
|
18
|
+
require "eitil_core/argument_helpers"
|
19
|
+
require "eitil_core/safe_executions"
|
20
|
+
require "eitil_core/setters"
|
21
|
+
require "eitil_core/validations"
|
22
|
+
require "eitil_core/lookups"
|
23
|
+
require "eitil_core/concerns"
|
24
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
# require "eitil_core/application_record/all_associations"
|
3
|
+
|
4
|
+
module EitilCore
|
5
|
+
module ApplicationRecord
|
6
|
+
module AllAssociations
|
7
|
+
|
8
|
+
def all_associations
|
9
|
+
reflect_on_all_associations.map do |assoc|
|
10
|
+
{ assoc.name => assoc.association_class.to_s.demodulize }
|
11
|
+
end.inject &:merge
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
# require "eitil_core/application_record/find_by_like"
|
3
|
+
|
4
|
+
module EitilCore
|
5
|
+
module ApplicationRecord
|
6
|
+
module FindByLike
|
7
|
+
|
8
|
+
def find_by_like(_hash)
|
9
|
+
column, like = _hash.first
|
10
|
+
find_by("LOWER(#{column}) LIKE ?", "%#{like.downcase}%")
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|