eitil 2.0.1 → 2.0.5
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/README.md +0 -1
- data/eitil_integrate/lib/eitil_integrate/application_exporter.rb +0 -1
- data/lib/eitil/railtie.rb +2 -3
- data/lib/eitil/version.rb +1 -1
- data/spec/dummy_app/app/models/user.rb +0 -25
- data/spec/spec_helper.rb +0 -2
- metadata +2 -25
- data/eitil_integrate/lib/eitil_integrate/application_exporter/lookups.rb +0 -50
- data/eitil_wrapper/README.md +0 -271
- data/eitil_wrapper/lib/eitil_wrapper/callbacks/helper_methods.rb +0 -118
- data/eitil_wrapper/lib/eitil_wrapper/callbacks.rb +0 -2
- data/eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb +0 -34
- data/eitil_wrapper/lib/eitil_wrapper/jobs/new_job_now.rb +0 -37
- data/eitil_wrapper/lib/eitil_wrapper/jobs/single_method_job.rb +0 -11
- data/eitil_wrapper/lib/eitil_wrapper/jobs.rb +0 -4
- data/eitil_wrapper/lib/eitil_wrapper/railtie.rb +0 -94
- data/eitil_wrapper/lib/eitil_wrapper/records/default_calculators.rb +0 -104
- data/eitil_wrapper/lib/eitil_wrapper/records/default_scopes.rb +0 -95
- data/eitil_wrapper/lib/eitil_wrapper/records/default_sorts.rb +0 -81
- data/eitil_wrapper/lib/eitil_wrapper/records.rb +0 -4
- data/eitil_wrapper/lib/eitil_wrapper/request_logger/controller_mixin.rb +0 -48
- data/eitil_wrapper/lib/eitil_wrapper/request_logger/logger_job.rb +0 -17
- data/eitil_wrapper/lib/eitil_wrapper/request_logger.rb +0 -5
- data/eitil_wrapper/lib/eitil_wrapper/routes/extended_resources.rb +0 -40
- data/eitil_wrapper/lib/eitil_wrapper/routes.rb +0 -2
- data/eitil_wrapper/lib/eitil_wrapper.rb +0 -8
- data/spec/eitil_wrapper/callbacks/helper_methods_spec.rb +0 -34
- data/spec/eitil_wrapper/jobs/single_method_job_spec.rb +0 -72
- data/spec/eitil_wrapper/routes/extended_resources_spec.rb +0 -16
- data/spec/eitil_wrapper/scopes/default_scopes_spec.rb +0 -154
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2edc24dc4673e9c8eabc8340bbdb05bcf714b0a657b963df0a31a585e9577a9d
|
4
|
+
data.tar.gz: ac24d95b97cf8c7ad21719264a5d8519d11e8d3eddee862c97a9dbc264b96768
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db7b2af3252a1e6443b8a22e6555ff61ebb4df435963e8b42b872a2fa219f1a3286fa6abaf3c5905d61918c98df48a04b355d84b6c84604640549ed690599971
|
7
|
+
data.tar.gz: 23c9459574092284fcf095cd8bb4a1ca41f97a1e5013caad874058ee9dece9f03411fe281a37ccec4bd2d619b40aff70db0285ac1177421aa4cc974a70b39efb
|
data/README.md
CHANGED
@@ -12,7 +12,6 @@ Our gem currently exists of five seperate layers (Railties), which can be integr
|
|
12
12
|
|
13
13
|
- EitilCore, [docs](/eitil_core) > extends the core classes of Ruby and rails.
|
14
14
|
- EitilSupport, [docs](/eitil_support) > provides utility through stand-alone classes and modules.
|
15
|
-
- EitilWrapper, [docs](/eitil_wrapper) > wraps core rails operations with extended utilities – such as routing, jobs and decoraters.
|
16
15
|
- EitilStore, [docs](/eitil_store) > stores data in containers, such as Regexp instances.
|
17
16
|
- EitilIntegrate, [docs](/eitil_integrate) > provides seamless integrations with select gems and API's, through helper methods stored in PORO's.
|
18
17
|
|
@@ -15,7 +15,6 @@ require_relative "application_exporter/style_cells"
|
|
15
15
|
require_relative "application_exporter/store_file"
|
16
16
|
require_relative "application_exporter/setters"
|
17
17
|
require_relative "application_exporter/selectors"
|
18
|
-
require_relative "application_exporter/lookups"
|
19
18
|
require_relative "application_exporter/infos"
|
20
19
|
require_relative "application_exporter/log_state"
|
21
20
|
|
data/lib/eitil/railtie.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
module Eitil
|
7
7
|
|
8
8
|
Root = Gem.loaded_specs['eitil']&.full_gem_path
|
9
|
-
Layers = %w( eitil_core eitil_support
|
9
|
+
Layers = %w( eitil_core eitil_support eitil_store eitil_integrate )
|
10
10
|
ApplicationRecordModules = []
|
11
11
|
|
12
12
|
end
|
@@ -45,10 +45,9 @@ module Eitil
|
|
45
45
|
yield Eitil
|
46
46
|
end
|
47
47
|
|
48
|
-
config_path = Rails.root + 'config/initializers/eitil.rb'
|
48
|
+
config_path = Rails.root + 'config/initializers/internal_engines/eitil.rb'
|
49
49
|
|
50
50
|
if File.exists? config_path
|
51
|
-
puts "Loading Eitil config from #{config_path}..."
|
52
51
|
load config_path
|
53
52
|
else
|
54
53
|
puts "Eitil config not found at #{config_path}, resorting to defaults..."
|
data/lib/eitil/version.rb
CHANGED
@@ -2,29 +2,4 @@ class User < ApplicationRecord
|
|
2
2
|
|
3
3
|
has_one :address
|
4
4
|
|
5
|
-
# ---
|
6
|
-
# below are methods, used for testing EitilWrapper::Jobs
|
7
|
-
|
8
|
-
def self.this_is_a_singleton_method(positional_value = nil, keyword_value: nil)
|
9
|
-
"this is a singleton method"
|
10
|
-
return positional_value if positional_value
|
11
|
-
return keyword_value if keyword_value
|
12
|
-
return nil
|
13
|
-
end
|
14
|
-
|
15
|
-
new_job :this_is_a_singleton_method
|
16
|
-
new_job_now :this_is_a_singleton_method
|
17
|
-
|
18
|
-
def this_is_an_instance_method(positional_value = nil, keyword_value: nil)
|
19
|
-
"this is an instance method"
|
20
|
-
return positional_value if positional_value
|
21
|
-
return keyword_value if keyword_value
|
22
|
-
return nil
|
23
|
-
end
|
24
|
-
|
25
|
-
new_job :this_is_an_instance_method
|
26
|
-
new_job_now :this_is_an_instance_method
|
27
|
-
|
28
|
-
# ---
|
29
|
-
|
30
5
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -8,13 +8,11 @@ require 'eitil'
|
|
8
8
|
|
9
9
|
require "eitil_core/railtie"
|
10
10
|
require "eitil_integrate/railtie"
|
11
|
-
require "eitil_wrapper/railtie"
|
12
11
|
# require "eitil_store/railtie"
|
13
12
|
# require "eitil_support/railtie"
|
14
13
|
|
15
14
|
require "eitil_core"
|
16
15
|
require "eitil_integrate"
|
17
|
-
require "eitil_wrapper"
|
18
16
|
# require "eitil_store"
|
19
17
|
# require "eitil_support"
|
20
18
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eitil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jurriaan Schrofer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -246,7 +246,6 @@ files:
|
|
246
246
|
- eitil_integrate/lib/eitil_integrate/application_exporter/infos.rb
|
247
247
|
- eitil_integrate/lib/eitil_integrate/application_exporter/initialize.rb
|
248
248
|
- eitil_integrate/lib/eitil_integrate/application_exporter/log_state.rb
|
249
|
-
- eitil_integrate/lib/eitil_integrate/application_exporter/lookups.rb
|
250
249
|
- eitil_integrate/lib/eitil_integrate/application_exporter/selectors.rb
|
251
250
|
- eitil_integrate/lib/eitil_integrate/application_exporter/setters.rb
|
252
251
|
- eitil_integrate/lib/eitil_integrate/application_exporter/store_file.rb
|
@@ -271,24 +270,6 @@ files:
|
|
271
270
|
- eitil_support/lib/eitil_support/stacktrace/audit.rb
|
272
271
|
- eitil_support/lib/eitil_support/stacktrace/call.rb
|
273
272
|
- eitil_support/lib/eitil_support/stacktrace/stack.rb
|
274
|
-
- eitil_wrapper/README.md
|
275
|
-
- eitil_wrapper/lib/eitil_wrapper.rb
|
276
|
-
- eitil_wrapper/lib/eitil_wrapper/callbacks.rb
|
277
|
-
- eitil_wrapper/lib/eitil_wrapper/callbacks/helper_methods.rb
|
278
|
-
- eitil_wrapper/lib/eitil_wrapper/jobs.rb
|
279
|
-
- eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb
|
280
|
-
- eitil_wrapper/lib/eitil_wrapper/jobs/new_job_now.rb
|
281
|
-
- eitil_wrapper/lib/eitil_wrapper/jobs/single_method_job.rb
|
282
|
-
- eitil_wrapper/lib/eitil_wrapper/railtie.rb
|
283
|
-
- eitil_wrapper/lib/eitil_wrapper/records.rb
|
284
|
-
- eitil_wrapper/lib/eitil_wrapper/records/default_calculators.rb
|
285
|
-
- eitil_wrapper/lib/eitil_wrapper/records/default_scopes.rb
|
286
|
-
- eitil_wrapper/lib/eitil_wrapper/records/default_sorts.rb
|
287
|
-
- eitil_wrapper/lib/eitil_wrapper/request_logger.rb
|
288
|
-
- eitil_wrapper/lib/eitil_wrapper/request_logger/controller_mixin.rb
|
289
|
-
- eitil_wrapper/lib/eitil_wrapper/request_logger/logger_job.rb
|
290
|
-
- eitil_wrapper/lib/eitil_wrapper/routes.rb
|
291
|
-
- eitil_wrapper/lib/eitil_wrapper/routes/extended_resources.rb
|
292
273
|
- lib/eitil.rb
|
293
274
|
- lib/eitil/all.rb
|
294
275
|
- lib/eitil/railtie.rb
|
@@ -437,10 +418,6 @@ files:
|
|
437
418
|
- spec/eitil_core/type_checkers/is_num_or_nan_spec.rb
|
438
419
|
- spec/eitil_integrate/application_exporter/auto_sum_spec.rb
|
439
420
|
- spec/eitil_integrate/application_exporter/initialize_spec.rb
|
440
|
-
- spec/eitil_wrapper/callbacks/helper_methods_spec.rb
|
441
|
-
- spec/eitil_wrapper/jobs/single_method_job_spec.rb
|
442
|
-
- spec/eitil_wrapper/routes/extended_resources_spec.rb
|
443
|
-
- spec/eitil_wrapper/scopes/default_scopes_spec.rb
|
444
421
|
- spec/spec_helper.rb
|
445
422
|
homepage: https://github.com/eitje-app/eitil_engine
|
446
423
|
licenses:
|
@@ -1,50 +0,0 @@
|
|
1
|
-
|
2
|
-
# require "eitil_integrate/application_exporter/lookups"
|
3
|
-
|
4
|
-
require "eitil_integrate/application_exporter/initialize"
|
5
|
-
require "eitil_support/directory"
|
6
|
-
|
7
|
-
module EitilIntegrate::RubyXL
|
8
|
-
class ApplicationExporter
|
9
|
-
|
10
|
-
class << self
|
11
|
-
|
12
|
-
def exporter_paths
|
13
|
-
EitilSupport::Directory.files('app/views/exporters/exporters').select { |path| path.end_with? '_exporter.rb' }
|
14
|
-
end
|
15
|
-
|
16
|
-
def exporter_names
|
17
|
-
exporter_paths.map { |path| path.split('/').last.remove('.rb').camelcase }
|
18
|
-
end
|
19
|
-
|
20
|
-
def exporter_constants
|
21
|
-
exporter_names.map &:constantize
|
22
|
-
end
|
23
|
-
|
24
|
-
def exporter_infos
|
25
|
-
exporter_constants.map { |_c| { "#{_c.to_s.remove("Exporter")}": _c.info || {} } }.inject &:merge
|
26
|
-
end
|
27
|
-
|
28
|
-
def exporter_info(exporter, info)
|
29
|
-
exporter_infos[exporter]&.dig(info)
|
30
|
-
end
|
31
|
-
|
32
|
-
# returns the exporter_infos, without the datatypes – for taxonomy purpuses, the field
|
33
|
-
# names are often sufficient
|
34
|
-
def exporter_taxonomy
|
35
|
-
parameter_fields = exporter_infos.transform_values { |v| v.select { |k,v| k == :required || k == :optional } }
|
36
|
-
|
37
|
-
parameter_fields.transform_values do |setting_collection|
|
38
|
-
setting_collection.transform_values do |setting|
|
39
|
-
setting.map { |key| key.is_a?(Hash) ? key.keys : key }.flatten
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def exporter_params
|
45
|
-
exporter_infos.transform_values { |v| [v[:required], v[:optional]].flatten.compact }
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
data/eitil_wrapper/README.md
DELETED
@@ -1,271 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
# EitilWrapper
|
5
|
-
|
6
|
-
EitilWrapper wraps core rails operations with extended utilities – such as routing, jobs and decoraters.
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
## EitilWrapper::Callbacks
|
14
|
-
|
15
|
-
```ruby
|
16
|
-
|
17
|
-
require "eitil_wrapper/callbacks"
|
18
|
-
|
19
|
-
```
|
20
|
-
|
21
|
-
Callback helper methods are created for use within a model's callbacks. You can use them as callback conditionals, e.g. "after_save :do_this, if :doing_became_true". Which scopes are generated depends on the datatype of a column. The methods currently generated are:
|
22
|
-
|
23
|
-
```ruby
|
24
|
-
# require "eitil_wrapper/callbacks/helper_methods"
|
25
|
-
|
26
|
-
# columns of datatype: boolean
|
27
|
-
.{column_name}_became_true
|
28
|
-
.{column_name}_becomes_true
|
29
|
-
.{column_name}_to_true # works for both become and became
|
30
|
-
|
31
|
-
.{column_name}_became_false
|
32
|
-
.{column_name}_becomes_false
|
33
|
-
.{column_name}_to_false # works for both become and became
|
34
|
-
```
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
## EitilWrapper::Jobs
|
41
|
-
|
42
|
-
```ruby
|
43
|
-
|
44
|
-
require "eitil_wrapper/jobs"
|
45
|
-
|
46
|
-
```
|
47
|
-
|
48
|
-
The Eitil jobs wrapper enables you to create perform_now and perform_later jobs on the fly, without the need to create a new class and file.
|
49
|
-
|
50
|
-
The macro new_job accepts a :method as argument and defines a new method :method_job. The newly defined :method_job, when called, performs the orginal :method in the background. The new_job macro accepts both instance methods and singleton methods, which are defined within there own method scope.
|
51
|
-
|
52
|
-
In contrast, the new_job_now macro defines a new :method_job_now method, which performs in the foreground.
|
53
|
-
|
54
|
-
```ruby
|
55
|
-
# require "eitil_wrapper/jobs/new_job"
|
56
|
-
|
57
|
-
new_job(_method, *args, **kwargs)
|
58
|
-
# assuming a method :hello_world, call as: new_job :hello_world
|
59
|
-
# => defines :hello_world_job
|
60
|
-
```
|
61
|
-
|
62
|
-
```ruby
|
63
|
-
# require "eitil_wrapper/jobs/new_job_now"
|
64
|
-
|
65
|
-
new_job_now(_method, *args, **kwargs)
|
66
|
-
# assuming a method :hello_world, call as: new_job_now :hello_world
|
67
|
-
# => defines :hello_world_job_now
|
68
|
-
```
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
## EitilWrapper::Routes
|
75
|
-
|
76
|
-
```ruby
|
77
|
-
|
78
|
-
require "eitil_wrapper/routes"
|
79
|
-
|
80
|
-
```
|
81
|
-
|
82
|
-
The Eitil router wrapper enables you to easily create new routes that can be shared among controllers. In that sense, it is as a custom extension of the built-in resourceful routes.
|
83
|
-
|
84
|
-
### New route
|
85
|
-
|
86
|
-
The first macro, .new_route, enables you to create new route objects which may be called and used by different controllers.
|
87
|
-
|
88
|
-
```ruby
|
89
|
-
# require "eitil_wrapper/routes/extended_resources"
|
90
|
-
|
91
|
-
new_route(verb, _method, action, scope)
|
92
|
-
# call as: new_route :post, :attachment, "add_attachment", :member
|
93
|
-
```
|
94
|
-
|
95
|
-
- verb refers to the http_verb, e.g. :put.
|
96
|
-
- method refers to the given http method (e.g. 'users/:id'). Additionally, this is the name you will refer to in order to include the route into a controller. Therefore the argument should be unique among all other routes.
|
97
|
-
- action refers to the controller action to which you want to redirect to request, e.g. :update_user.
|
98
|
-
- scope refers to the url and can be set to either :member or :collection.
|
99
|
-
|
100
|
-
### Add route
|
101
|
-
|
102
|
-
The second macro, extended_resources, enables you to create all standard resources for a controller and add your own standardized routes. This macro works the same as the built-in :resources, except that you can pass more arguments to only: [], which adds the routes to your controller.
|
103
|
-
|
104
|
-
```ruby
|
105
|
-
# require "eitil_wrapper/routes/extended_resources"
|
106
|
-
|
107
|
-
extended_resources(controller, **kwargs)
|
108
|
-
# call as: extended_resources :posts, only: [:create, :update, :attachment]
|
109
|
-
```
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
## EitilWrapper::Records
|
116
|
-
|
117
|
-
```ruby
|
118
|
-
|
119
|
-
# include all below EitilWrapper::Records helpers through:
|
120
|
-
require "eitil_wrapper/records"
|
121
|
-
|
122
|
-
```
|
123
|
-
|
124
|
-
### Scopes
|
125
|
-
|
126
|
-
```ruby
|
127
|
-
|
128
|
-
require "eitil_wrapper/records/scopes"
|
129
|
-
|
130
|
-
```
|
131
|
-
|
132
|
-
Scopes are generated through the columns of your model's database table. Which scopes are generated depends on the datatype of a column. For example, if your User model with table users has a column is_manager, a scope :is_manager_true is generated for your User model. A scope method is defined only if it does not already responds to another method of the same name. The scopes generated are:
|
133
|
-
|
134
|
-
```ruby
|
135
|
-
# require "eitil_wrapper/scopes/default_scopes"
|
136
|
-
|
137
|
-
# columns of datatype: boolean
|
138
|
-
.{column_name}_true
|
139
|
-
.{column_name}_false
|
140
|
-
|
141
|
-
# columns of datatype: datetime
|
142
|
-
.{column_name}_today
|
143
|
-
.{column_name}_past
|
144
|
-
.{column_name}_future
|
145
|
-
.{column_name}_on_date(date)
|
146
|
-
.{column_name}_before_date(date)
|
147
|
-
.{column_name}_after_date(date)
|
148
|
-
.{column_name}_between_dates(start_date, end_date)
|
149
|
-
|
150
|
-
# columns of datatype: date
|
151
|
-
.{column_name}_today
|
152
|
-
.{column_name}_past
|
153
|
-
.{column_name}_future
|
154
|
-
.{column_name}_on_date(date)
|
155
|
-
.{column_name}_before_date(date)
|
156
|
-
.{column_name}_after_date(date)
|
157
|
-
.{column_name}_between_dates(start_date, end_date)
|
158
|
-
|
159
|
-
# columns of datatype: integer
|
160
|
-
.{column_name}_equal_to(number)
|
161
|
-
.{column_name}_lower_than(number)
|
162
|
-
.{column_name}_higher_than(number)
|
163
|
-
.{column_name}_between(min, max)
|
164
|
-
|
165
|
-
# columns of datatype: float
|
166
|
-
.{column_name}_equal_to(number)
|
167
|
-
.{column_name}_lower_than(number)
|
168
|
-
.{column_name}_higher_than(number)
|
169
|
-
.{column_name}_between(min, max)
|
170
|
-
```
|
171
|
-
|
172
|
-
### Sorts
|
173
|
-
|
174
|
-
|
175
|
-
```ruby
|
176
|
-
|
177
|
-
require "eitil_wrapper/records/sorts"
|
178
|
-
|
179
|
-
```
|
180
|
-
|
181
|
-
Sorts are generated through the columns of your model's database table. Which sorts are generated depends on the datatype of a column. A sort method is defined only if it does not already responds to another method of the same name. The sorts generated are:
|
182
|
-
|
183
|
-
```ruby
|
184
|
-
# require "eitil_wrapper/scopes/default_scopes"
|
185
|
-
|
186
|
-
# columns of datatype: datetime
|
187
|
-
.{column_name}_oldest_first
|
188
|
-
.{column_name}_newest_first
|
189
|
-
|
190
|
-
# columns of datatype: date
|
191
|
-
.{column_name}_oldest_first
|
192
|
-
.{column_name}_newest_first
|
193
|
-
|
194
|
-
# columns of datatype: integer
|
195
|
-
.{column_name}_ascending
|
196
|
-
.{column_name}_descending
|
197
|
-
|
198
|
-
# columns of datatype: float
|
199
|
-
.{column_name}_ascending
|
200
|
-
.{column_name}_descending
|
201
|
-
```
|
202
|
-
|
203
|
-
|
204
|
-
### Calculators
|
205
|
-
|
206
|
-
|
207
|
-
```ruby
|
208
|
-
|
209
|
-
require "eitil_wrapper/records/calculators"
|
210
|
-
|
211
|
-
```
|
212
|
-
|
213
|
-
Calculators are generated through the columns of your model's database table. Which calculators are generated depends on the datatype of a column. A calculator method is defined only if it does not already responds to another method of the same name. The calculators generated are:
|
214
|
-
|
215
|
-
```ruby
|
216
|
-
# require "eitil_wrapper/scopes/default_scopes"
|
217
|
-
|
218
|
-
# columns of datatype: array (serialized)
|
219
|
-
.{column_name}_sum # returns all uniq elements in a new, single array
|
220
|
-
.{column_name}_sum_i # sum and map to integer
|
221
|
-
.{column_name}_sum_f # sum and map to float
|
222
|
-
.{column_name}_sum_d # sum and map to decimal
|
223
|
-
|
224
|
-
# columns of datatype: integer
|
225
|
-
.{column_name}_max
|
226
|
-
.{column_name}_min
|
227
|
-
.{column_name}_sum
|
228
|
-
.{column_name}_avg
|
229
|
-
|
230
|
-
# columns of datatype: float
|
231
|
-
.{column_name}_max
|
232
|
-
.{column_name}_min
|
233
|
-
.{column_name}_sum
|
234
|
-
.{column_name}_avg
|
235
|
-
|
236
|
-
# columns of datatype: decimal
|
237
|
-
.{column_name}_max
|
238
|
-
.{column_name}_min
|
239
|
-
.{column_name}_sum
|
240
|
-
.{column_name}_avg
|
241
|
-
|
242
|
-
# columns of datatype: bigint
|
243
|
-
.{column_name}_max
|
244
|
-
.{column_name}_min
|
245
|
-
.{column_name}_sum
|
246
|
-
.{column_name}_avg
|
247
|
-
```
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
## EitilWrapper::RequestLogger
|
252
|
-
|
253
|
-
```ruby
|
254
|
-
|
255
|
-
require "eitil_wrapper/request_logger"
|
256
|
-
|
257
|
-
```
|
258
|
-
|
259
|
-
The RequestLogger wrapper logs request params in /log/request_logger.log, which offers the opportunity to pry into webhooks while developing. In order to track a controller, simply add the following. This calls a background job which writes to the file.
|
260
|
-
|
261
|
-
```ruby
|
262
|
-
|
263
|
-
include EitilWrapper::RequestLogger::ControllerMixin
|
264
|
-
before_action :log_request
|
265
|
-
|
266
|
-
```
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
@@ -1,118 +0,0 @@
|
|
1
|
-
|
2
|
-
# require "eitil_wrapper/callbacks/helper_methods"
|
3
|
-
|
4
|
-
# require "eitil_wrapper/railtie" to run the dynamic dispatch as an init hook during boot
|
5
|
-
require "eitil_wrapper/railtie"
|
6
|
-
|
7
|
-
require "eitil_core/argument_helpers/all_args_to_ivars"
|
8
|
-
|
9
|
-
module EitilWrapper
|
10
|
-
module Callbacks
|
11
|
-
module HelperMethods
|
12
|
-
|
13
|
-
Eitil::ApplicationRecordModules << self
|
14
|
-
|
15
|
-
def inherited(subclass)
|
16
|
-
super
|
17
|
-
return if Eitil.skip_callback_helper_methods_for_models.include?(subclass.to_s.to_sym)
|
18
|
-
|
19
|
-
# Set the proper table_names for namespaced models. Without setting this,
|
20
|
-
# Rails run into problems due to the fact that the first call to the model's
|
21
|
-
# constant triggers this initializer first, and only thereafter the model file
|
22
|
-
# which sets the correct table_name through a macro.
|
23
|
-
namespaced_class = subclass.to_s.include?('::')
|
24
|
-
subclass.table_name = subclass.to_s.gsub('::', '_').downcase.pluralize if namespaced_class
|
25
|
-
|
26
|
-
subclass.use_eitil_callback_helper_methods
|
27
|
-
|
28
|
-
rescue => e
|
29
|
-
puts "callback helper methods failed for #{subclass} because of #{e.class} and '#{e.to_s.split(' ').first}'"
|
30
|
-
end
|
31
|
-
|
32
|
-
def use_eitil_callback_helper_methods
|
33
|
-
return if abstract_class?
|
34
|
-
create_eitil_boolean_callback_helper_methods
|
35
|
-
end
|
36
|
-
|
37
|
-
def columns_of_type(data_type)
|
38
|
-
columns_hash.select { |column,v| v.sql_type_metadata.type == data_type }
|
39
|
-
end
|
40
|
-
|
41
|
-
def create_eitil_boolean_callback_helper_methods
|
42
|
-
columns = columns_of_type :boolean
|
43
|
-
columns&.each do |column_name, eitil_object|
|
44
|
-
|
45
|
-
# truthy methods
|
46
|
-
create_eitil_became_true_callback_helper column_name
|
47
|
-
create_eitil_becomes_true_callback_helper column_name
|
48
|
-
create_eitil_to_true_callback_helper column_name
|
49
|
-
|
50
|
-
# falsy methods
|
51
|
-
create_eitil_became_false_callback_helper column_name
|
52
|
-
create_eitil_becomes_false_callback_helper column_name
|
53
|
-
create_eitil_to_false_callback_helper column_name
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def create_eitil_became_true_callback_helper(column_name)
|
59
|
-
method_name = "#{column_name}_became_true"
|
60
|
-
|
61
|
-
define_method(method_name) do
|
62
|
-
_changes = previous_changes[column_name]
|
63
|
-
_changes && !_changes[0] && _changes[1]
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def create_eitil_becomes_true_callback_helper(column_name)
|
68
|
-
method_name = "#{column_name}_becomes_true"
|
69
|
-
|
70
|
-
define_method(method_name) do
|
71
|
-
_changes = changes[column_name]
|
72
|
-
_changes && !_changes[0] && _changes[1]
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def create_eitil_to_true_callback_helper(column_name)
|
77
|
-
method_name = "#{column_name}_to_true"
|
78
|
-
becomes_method = "#{column_name}_becomes_true"
|
79
|
-
became_method = "#{column_name}_became_true"
|
80
|
-
|
81
|
-
define_method(method_name) do
|
82
|
-
return send(becomes_method) if changes&.present?
|
83
|
-
return send(became_method) if previous_changes&.present?
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def create_eitil_became_false_callback_helper(column_name)
|
88
|
-
method_name = "#{column_name}_became_false"
|
89
|
-
|
90
|
-
define_method(method_name) do
|
91
|
-
_changes = previous_changes[column_name]
|
92
|
-
_changes && _changes[0] && !_changes[1]
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def create_eitil_becomes_false_callback_helper(column_name)
|
97
|
-
method_name = "#{column_name}_becomes_false"
|
98
|
-
|
99
|
-
define_method(method_name) do
|
100
|
-
_changes = changes[column_name]
|
101
|
-
_changes && _changes[0] && !_changes[1]
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def create_eitil_to_false_callback_helper(column_name)
|
106
|
-
method_name = "#{column_name}_to_false"
|
107
|
-
becomes_method = "#{column_name}_becomes_false"
|
108
|
-
became_method = "#{column_name}_became_false"
|
109
|
-
|
110
|
-
define_method(method_name) do
|
111
|
-
return send(becomes_method) if changes&.present?
|
112
|
-
return send(became_method) if previous_changes&.present?
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
|
2
|
-
# require "eitil_wrapper/jobs/new_job"
|
3
|
-
|
4
|
-
require "eitil_wrapper/jobs/single_method_job"
|
5
|
-
|
6
|
-
Kernel.module_eval do
|
7
|
-
|
8
|
-
# BEWARE: _self is currently not accepted in perform_later jobs due to serialization errors
|
9
|
-
|
10
|
-
# The cases of 'id' and '_self' both handle instances, with the difference
|
11
|
-
# being that 'id' works for objects that have a database record, while '_self'
|
12
|
-
# works for non database supported instanes, such as an Exporter instance.
|
13
|
-
|
14
|
-
def new_job(_method, *args, **kwargs)
|
15
|
-
|
16
|
-
if instance_methods(false).include? _method
|
17
|
-
define_method "#{_method}_job" do |_self = nil, *args, **kwargs|
|
18
|
-
|
19
|
-
EitilWrapper::SingleMethodJob.perform_later(
|
20
|
-
*args, _class: self.class.to_s, _method: _method.to_s, id: safe_send(:id), _self: self.to_json, **kwargs
|
21
|
-
)
|
22
|
-
end
|
23
|
-
|
24
|
-
elsif singleton_methods(false).include? _method
|
25
|
-
define_singleton_method "#{_method}_job" do |*args, **kwargs|
|
26
|
-
|
27
|
-
EitilWrapper::SingleMethodJob.perform_later(
|
28
|
-
*args, _class: to_s, _method: _method.to_s, **kwargs
|
29
|
-
)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
|
2
|
-
# require "eitil_wrapper/jobs/new_job_now"
|
3
|
-
|
4
|
-
require "eitil_wrapper/jobs/single_method_job"
|
5
|
-
|
6
|
-
# BEWARE: This is an exact copy of the .new_job method, except for .perform_now instead of .perform_later and the method's name.
|
7
|
-
# The reason for not using helper methods is to not unnecessarily fill and potentially fuck up the Kernel environment.
|
8
|
-
|
9
|
-
Kernel.module_eval do
|
10
|
-
|
11
|
-
# BEWARE: _self is currently not accepted in perform_later jobs due to serialization errors
|
12
|
-
|
13
|
-
# The cases of 'id' and '_self' both handle instances, with the difference
|
14
|
-
# being that 'id' works for objects that have a database record, while '_self'
|
15
|
-
# works for non database supported instanes, such as an Exporter instance.
|
16
|
-
|
17
|
-
def new_job_now(_method, *args, **kwargs)
|
18
|
-
|
19
|
-
if instance_methods(false).include? _method
|
20
|
-
define_method "#{_method}_job_now" do |_self = nil, *args, **kwargs|
|
21
|
-
|
22
|
-
EitilWrapper::SingleMethodJob.perform_now(
|
23
|
-
*args, _class: self.class.to_s, _method: _method.to_s, id: safe_send(:id), _self: self.to_json, **kwargs
|
24
|
-
)
|
25
|
-
end
|
26
|
-
|
27
|
-
elsif singleton_methods(false).include? _method
|
28
|
-
define_singleton_method "#{_method}_job_now" do |*args, **kwargs|
|
29
|
-
|
30
|
-
EitilWrapper::SingleMethodJob.perform_now(
|
31
|
-
*args, _class: to_s, _method: _method.to_s, **kwargs
|
32
|
-
)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|