itg 0.1.9 → 0.1.10
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 +19 -1
- data/lib/itg/controllers/itg_controller_set_current_request_details.rb +18 -0
- data/lib/itg/controllers/itg_entities_controller_base.rb +2 -2
- data/lib/itg/controllers/itg_generic_controller_base.rb +41 -40
- data/lib/itg/itg_api_key_authenticatable.rb +2 -0
- data/lib/itg/itg_current_base.rb +27 -0
- data/lib/itg/itg_printable.rb +2 -1
- data/lib/itg/itg_sec.rb +3 -3
- data/lib/itg/models/itg_context_model_base.rb +11 -1
- data/lib/itg/models/itg_entity_model_base.rb +3 -1
- data/lib/itg/models/itg_user_model_base.rb +14 -13
- data/lib/itg/version.rb +2 -2
- data/lib/itg.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe781750f5aa0333312d6a9fd50522d349b25d4c33459c82e9db8417c60e2ab1
|
4
|
+
data.tar.gz: 112e6866a3e64dfa33ecc755d69c40d44c4f460e8b91a8bbf0a3a19e14daacf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 569b0ef8c9e406792bbe4491bf841ce1558d26b6cfa206395b4d62368170a2741048f527cde8406666f973cbf2ad9b262fbd4e4cee3d54f53d3a2f0d00c1746e
|
7
|
+
data.tar.gz: 20df9342f243bb409fd467c97ef55a781abc3e1198142739488603c1625a81a485603da738131b684ea8c4bb388a49caa88665e72829b731763f79389cd7b4cb
|
data/README.md
CHANGED
@@ -1,4 +1,22 @@
|
|
1
|
-
# Itg
|
1
|
+
# Itg gem
|
2
|
+
|
3
|
+
### Context
|
4
|
+
|
5
|
+
The `Context` describes the isolated storage for the users data
|
6
|
+
|
7
|
+
Every time a user can see and manage only the data of a single `context` in which he has access
|
8
|
+
|
9
|
+
User has a list of contexts (memberships) where has access.
|
10
|
+
Each `context membership` has: `context`, `user`, `access` (`ro`, `rw`, `admin`)
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
2
20
|
|
3
21
|
TODO: Delete this and the text below, and describe your gem
|
4
22
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Itg
|
2
|
+
module ControllerSetCurrentRequestDetails
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
before_action do
|
7
|
+
Current.request_id = request.uuid
|
8
|
+
Current.user_agent = request.user_agent
|
9
|
+
Current.ip_address = request.ip
|
10
|
+
Current.host = request.host
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class_methods do
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -20,11 +20,11 @@ module Itg
|
|
20
20
|
# @g_model_class = Entity
|
21
21
|
@g_model_class = self.class.model_class
|
22
22
|
@g_search_field = 'kind'
|
23
|
-
@
|
23
|
+
@g_permitted_params = {kind: nil, tags: nil, context: nil, attrs: {}}
|
24
24
|
end
|
25
25
|
|
26
26
|
def set_model_instance
|
27
|
-
puts '******** entities_controller#set_model_instance......'
|
27
|
+
# puts '******** entities_controller#set_model_instance......'
|
28
28
|
ITG_LOGGER.info '*** [Entities.set_model_instance] ...'
|
29
29
|
@model_instance = @g_model_class.find(params[:id])
|
30
30
|
end
|
@@ -7,21 +7,22 @@ module Itg
|
|
7
7
|
included do
|
8
8
|
include Itg::Response
|
9
9
|
|
10
|
-
before_action :g_model_class, :g_parent_model_class, :g_search_field, :
|
10
|
+
before_action :g_model_class, :g_parent_model_class, :g_search_field, :g_permitted_params
|
11
11
|
# before_action :set_model_instance, only: [:show, :update, :destroy]
|
12
12
|
before_action :require_permission
|
13
13
|
before_action :switch_database
|
14
14
|
after_action :reset_database
|
15
15
|
|
16
16
|
def curr_user_db
|
17
|
-
@current_bearer ? @current_bearer.db : 'mainaaa'
|
17
|
+
# @current_bearer ? @current_bearer.db : 'mainaaa'
|
18
|
+
# 'test'
|
18
19
|
end
|
19
20
|
|
20
21
|
def index
|
21
|
-
puts "[GenericController.index] current_bearer: #{@current_bearer}, current_api_key: #{@current_api_key}"
|
22
|
-
puts "[GenericController.index] current_bearer.db: #{@current_bearer.db}, current_bearer.kind: #{@current_bearer.kind}"
|
23
|
-
puts "[GenericController.index] curr_user_db: #{curr_user_db}, params[:filter]: #{params[:filter]}"
|
24
|
-
pp "*** Api::V1::Cultivation::Chamber.count: #{Api::V1::Cultivation::Chamber.count}"
|
22
|
+
# puts "[GenericController.index] current_bearer: #{@current_bearer}, current_api_key: #{@current_api_key}"
|
23
|
+
# puts "[GenericController.index] current_bearer.db: #{@current_bearer.db}, current_bearer.kind: #{@current_bearer.kind}"
|
24
|
+
# puts "[GenericController.index] curr_user_db: #{curr_user_db}, params[:filter]: #{params[:filter]}"
|
25
|
+
# pp "*** Api::V1::Cultivation::Chamber.count: #{Api::V1::Cultivation::Chamber.count}"
|
25
26
|
ITG_LOGGER.info "*** [GenericController/#{@g_model_class}.index] params: #{params}\n params[:filter]: #{params[:filter]}\n db: #{@g_model_class.database_name}\n=========================="
|
26
27
|
collection = get_collection
|
27
28
|
# data = if (filter = params[:filter])
|
@@ -33,13 +34,13 @@ module Itg
|
|
33
34
|
# collection.all
|
34
35
|
# end
|
35
36
|
data = if (filter = params[:filter])
|
36
|
-
puts '----- with filter'
|
37
|
+
# puts '----- with filter'
|
37
38
|
collection.where(@g_search_field => /.*#{filter}.*/i)
|
38
39
|
else
|
39
|
-
puts '----- all'
|
40
|
+
# puts '----- all'
|
40
41
|
# pp collection.with(curr_user_db).all.count
|
41
|
-
pp collection.all.count
|
42
|
-
pp "*** Api::V1::Cultivation::Chamber.count: #{Api::V1::Cultivation::Chamber.count}"
|
42
|
+
# pp collection.all.count
|
43
|
+
# pp "*** Api::V1::Cultivation::Chamber.count: #{Api::V1::Cultivation::Chamber.count}"
|
43
44
|
collection.all
|
44
45
|
# Api::V1::Link.with(database: curr_user_db) { |klass| klass.all.to_a }
|
45
46
|
# collection.with(database: curr_user_db) { |klass| klass.all.to_a }
|
@@ -48,7 +49,7 @@ module Itg
|
|
48
49
|
# klass.all
|
49
50
|
# end
|
50
51
|
end
|
51
|
-
puts ">>>> collection '#{collection}' data (#{data.count}): #{data}"
|
52
|
+
# puts ">>>> collection '#{collection}' data (#{data.count}): #{data}"
|
52
53
|
if (view_name = params[:view])
|
53
54
|
data = data.respond_to?(view_name) ? data.send(view_name) : "View '#{view_name}' does not exist for collection '#{collection}'"
|
54
55
|
end
|
@@ -62,21 +63,21 @@ module Itg
|
|
62
63
|
# data = params[:filter] ? collection.where(@g_search_field => /.*#{params[:filter]}.*/i) : collection.all
|
63
64
|
# ITG_LOGGER.info "*** [GenericController/#{@g_model_class}.index] data to return (#{data.count}):\n#{JSON.pretty_generate data}\n============================"
|
64
65
|
# render json: params[:filter] ? @g_model_class.where(@g_search_field => /.*#{params[:filter]}.*/i) : @g_model_class.all
|
65
|
-
puts '>>>>>>> [GenericController.index] ....'
|
66
|
-
puts ">>>>>>> [GenericController.index] data (#{data.count if data})"
|
67
|
-
pp data
|
68
|
-
pp data
|
66
|
+
# puts '>>>>>>> [GenericController.index] ....'
|
67
|
+
# puts ">>>>>>> [GenericController.index] data (#{data.count if data})"
|
68
|
+
# pp data
|
69
|
+
# pp data
|
69
70
|
render json: data
|
70
71
|
end
|
71
72
|
|
72
73
|
def show
|
73
|
-
puts '>>>>>>> [GenericController.show] ...'
|
74
|
+
# puts '>>>>>>> [GenericController.show] ...'
|
74
75
|
ITG_LOGGER.info "*** [GenericController/#{@g_model_class}.show] params: #{params}\n params[:id]: #{params[:id]}\n db: #{@g_model_class.database_name}\n========================="
|
75
76
|
collection = get_collection
|
76
77
|
data = collection.find(params[:id])
|
77
|
-
ITG_LOGGER.info "*** [GenericController/#{@g_model_class}.show] data to return:\n#{JSON.pretty_generate data}\n============================"
|
78
|
-
puts ">>>>>>> [GenericController.show] collection: #{collection}"
|
79
|
-
pp data
|
78
|
+
ITG_LOGGER.info "*** [GenericController/#{@g_model_class}.show] data to return:\n#{JSON.pretty_generate data.to_s}\n============================"
|
79
|
+
# puts ">>>>>>> [GenericController.show] collection: #{collection}"
|
80
|
+
# pp data
|
80
81
|
if data
|
81
82
|
render json: data
|
82
83
|
else
|
@@ -85,7 +86,7 @@ module Itg
|
|
85
86
|
end
|
86
87
|
|
87
88
|
def create
|
88
|
-
puts '>>>>>>> [GenericController.create] ...'
|
89
|
+
# puts '>>>>>>> [GenericController.create] ...'
|
89
90
|
ITG_LOGGER.info "*** [GenericController/#{@g_model_class}.create] params:\n#{JSON.pretty_generate params}\n db: #{@g_model_class.database_name}\n============================"
|
90
91
|
# g_check_variables
|
91
92
|
# # ITG_LOGGER.info "*** [GenericController/#{@g_model_class}.create] model_instance_params:\n#{JSON.pretty_generate model_instance_params}\n============================"
|
@@ -128,7 +129,7 @@ module Itg
|
|
128
129
|
end
|
129
130
|
|
130
131
|
def update
|
131
|
-
puts '>>>>>>> [GenericController.update] ...'
|
132
|
+
# puts '>>>>>>> [GenericController.update] ...'
|
132
133
|
ITG_LOGGER.info "*** [GenericController/#{@g_model_class}.update] params:\n#{JSON.pretty_generate params}\n db: #{@g_model_class.database_name}\n============================"
|
133
134
|
g_check_variables
|
134
135
|
# @model_instance.update(model_instance_params)
|
@@ -155,7 +156,7 @@ module Itg
|
|
155
156
|
|
156
157
|
def destroy
|
157
158
|
g_check_variables
|
158
|
-
puts "*** [GenericController/#{@g_model_class}.destroy] params:\n#{JSON.pretty_generate params}\n db: #{@g_model_class.database_name}\n============================"
|
159
|
+
# puts "*** [GenericController/#{@g_model_class}.destroy] params:\n#{JSON.pretty_generate params}\n db: #{@g_model_class.database_name}\n============================"
|
159
160
|
ITG_LOGGER.info "*** [GenericController/#{@g_model_class}.destroy] params:\n#{JSON.pretty_generate params}\n db: #{@g_model_class.database_name}\n============================"
|
160
161
|
if @model_instance
|
161
162
|
@model_instance.destroy
|
@@ -168,7 +169,7 @@ module Itg
|
|
168
169
|
private
|
169
170
|
|
170
171
|
def switch_database
|
171
|
-
puts ">>> [GenericController.switch_database] curr_user_db: #{curr_user_db}"
|
172
|
+
# puts ">>> [GenericController.switch_database] curr_user_db: #{curr_user_db}"
|
172
173
|
# if params.has_key? 'test'
|
173
174
|
# # db_name = "md-test"
|
174
175
|
# db_name = 'itg_api_test'
|
@@ -187,7 +188,7 @@ module Itg
|
|
187
188
|
ITG_LOGGER.info '*** [GenericController.g_check_variables] ...'
|
188
189
|
raise '[GenericController] @g_model_class is nil!' unless @g_model_class
|
189
190
|
raise "[GenericController/#{@g_model_class}] @g_search_field is nil!" unless @g_search_field
|
190
|
-
raise "[GenericController/#{@g_model_class}] @
|
191
|
+
raise "[GenericController/#{@g_model_class}] @g_permitted_params is nil!" unless @g_permitted_params
|
191
192
|
end
|
192
193
|
|
193
194
|
def g_model_class
|
@@ -205,9 +206,9 @@ module Itg
|
|
205
206
|
@g_search_field ||= nil
|
206
207
|
end
|
207
208
|
|
208
|
-
def
|
209
|
-
ITG_LOGGER.info '*** [GenericController.
|
210
|
-
@
|
209
|
+
def g_permitted_params
|
210
|
+
ITG_LOGGER.info '*** [GenericController.g_permitted_params] ...'
|
211
|
+
@g_permitted_params ||= nil
|
211
212
|
end
|
212
213
|
|
213
214
|
def g_only_show
|
@@ -223,24 +224,24 @@ module Itg
|
|
223
224
|
# end
|
224
225
|
|
225
226
|
def model_instance_params(create = false)
|
226
|
-
puts '>>>>>>> [GenericController.model_instance_params] ...'
|
227
|
+
# puts '>>>>>>> [GenericController.model_instance_params] ...'
|
227
228
|
ITG_LOGGER.info '*** [GenericController.model_instance_params] ...'
|
228
229
|
ITG_LOGGER.info ">>>>> params: #{params}"
|
229
230
|
ITG_LOGGER.info ">>>>> @g_model_class: #{@g_model_class}"
|
230
231
|
# params_model_sym = @g_model_class.name.parameterize.underscore.to_sym
|
231
232
|
params_model_sym = @g_model_class.name.underscore.gsub('/', '_').to_sym
|
232
233
|
ITG_LOGGER.info ">>>>> params_model_sym: #{params_model_sym}"
|
233
|
-
ITG_LOGGER.info ">>>>> @
|
234
|
-
# ITG_LOGGER.info "*** [GenericController.model_instance_params]
|
235
|
-
# ret = params.require(@g_model_class.name.underscore.to_sym).permit(*@
|
234
|
+
ITG_LOGGER.info ">>>>> @g_permitted_params: #{@g_permitted_params}"
|
235
|
+
# ITG_LOGGER.info "*** [GenericController.model_instance_params] g_permitted_params:\n#{@g_permitted_params}"
|
236
|
+
# ret = params.require(@g_model_class.name.underscore.to_sym).permit(*@g_permitted_params)
|
236
237
|
|
237
|
-
case @
|
238
|
+
case @g_permitted_params
|
238
239
|
when Array
|
239
|
-
ret = params.require(params_model_sym).permit(*@
|
240
|
+
ret = params.require(params_model_sym).permit(*@g_permitted_params)
|
240
241
|
when Hash
|
241
|
-
ret = params.require(params_model_sym).permit(*@
|
242
|
+
ret = params.require(params_model_sym).permit(*@g_permitted_params, **@g_permitted_params)
|
242
243
|
else
|
243
|
-
raise "[GenericController.model_instance_params] unhandled @
|
244
|
+
raise "[GenericController.model_instance_params] unhandled @g_permitted_params: #{@g_permitted_params.inspect}"
|
244
245
|
end
|
245
246
|
|
246
247
|
ITG_LOGGER.info "*** [GenericController.model_instance_params] return:\n#{ret}"
|
@@ -261,12 +262,12 @@ module Itg
|
|
261
262
|
end
|
262
263
|
|
263
264
|
def get_collection
|
264
|
-
puts "*** [GenericController/#{@g_model_class}.get_collection] params: #{params}"
|
265
|
+
# puts "*** [GenericController/#{@g_model_class}.get_collection] params: #{params}"
|
265
266
|
ITG_LOGGER.info "*** [GenericController/#{@g_model_class}.get_collection] params: #{params}"
|
266
267
|
g_check_variables
|
267
268
|
if @g_parent_model_class
|
268
269
|
ITG_LOGGER.info "*** [GenericController/#{@g_model_class}.index] With parent: #{@g_parent_model_class}"
|
269
|
-
puts "*** [GenericController/#{@g_model_class}.index] With parent: #{@g_parent_model_class}"
|
270
|
+
# puts "*** [GenericController/#{@g_model_class}.index] With parent: #{@g_parent_model_class}"
|
270
271
|
collection_name = @g_model_class.to_s.parameterize.pluralize
|
271
272
|
parent_field_id = @g_parent_model_class.to_s.parameterize + '_id'
|
272
273
|
parent_id = params[parent_field_id.to_sym]
|
@@ -282,7 +283,7 @@ module Itg
|
|
282
283
|
end
|
283
284
|
else
|
284
285
|
ITG_LOGGER.info "*** [GenericController/#{@g_model_class}.index] NO parent...."
|
285
|
-
puts "*** [GenericController/#{@g_model_class}.index] NO parent...."
|
286
|
+
# puts "*** [GenericController/#{@g_model_class}.index] NO parent...."
|
286
287
|
collection = @g_model_class
|
287
288
|
# data = params[:filter] ? @g_model_class.where(@g_search_field => /.*#{params[:filter]}.*/i) : @g_model_class.all
|
288
289
|
end
|
@@ -291,12 +292,12 @@ module Itg
|
|
291
292
|
|
292
293
|
def require_permission
|
293
294
|
if @g_model_class.attribute_names.include?('owner_id')
|
294
|
-
puts "******** generic_controller#require_permission @model_instance.owner: #{@model_instance&.owner}, @model_instance: #{@model_instance}"
|
295
|
+
# puts "******** generic_controller#require_permission @model_instance.owner: #{@model_instance&.owner}, @model_instance: #{@model_instance}"
|
295
296
|
if @model_instance && @model_instance.owner_id != @current_bearer.id
|
296
297
|
json_response('Not allowed!', :forbidden)
|
297
298
|
end
|
298
299
|
else
|
299
|
-
puts "******** generic_controller#require_permission @current_bearer: #{@current_bearer.inspect}, @model_instance: #{@model_instance.inspect}"
|
300
|
+
# puts "******** generic_controller#require_permission @current_bearer: #{@current_bearer.inspect}, @model_instance: #{@model_instance.inspect}"
|
300
301
|
unless @current_bearer.kind == 'one'
|
301
302
|
json_response('Not allowed!', :forbidden)
|
302
303
|
end
|
@@ -15,11 +15,13 @@ module Itg
|
|
15
15
|
# code when API key authentication fails
|
16
16
|
def authenticate_with_api_key!
|
17
17
|
@current_bearer = authenticate_or_request_with_http_token(&method(:authenticator))
|
18
|
+
Current.user = @current_bearer
|
18
19
|
end
|
19
20
|
|
20
21
|
# Use this for optional API key authentication
|
21
22
|
def authenticate_with_api_key
|
22
23
|
@current_bearer = authenticate_with_http_token(&method(:authenticator))
|
24
|
+
Current.user = @current_bearer
|
23
25
|
end
|
24
26
|
|
25
27
|
private
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Itg
|
2
|
+
module CurrentBase
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attribute :user
|
7
|
+
attribute :context
|
8
|
+
attribute :config
|
9
|
+
attribute :request_id, :user_agent, :ip_address, :host
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
ret_hash = {}
|
13
|
+
ret_hash[:user] = user.username if user
|
14
|
+
ret_hash[:request_id] = request_id if request_id
|
15
|
+
ret_hash[:user_agent] = user_agent if user_agent
|
16
|
+
ret_hash[:host] = host if host
|
17
|
+
ret_hash[:ip_address] = ip_address if ip_address
|
18
|
+
if ret_hash.empty?
|
19
|
+
"Current singleton is empty"
|
20
|
+
else
|
21
|
+
# ret_hash.to_a.join(', ')
|
22
|
+
"Current is #{ret_hash.inspect}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/itg/itg_printable.rb
CHANGED
data/lib/itg/itg_sec.rb
CHANGED
@@ -19,12 +19,12 @@ module Itg
|
|
19
19
|
|
20
20
|
included do
|
21
21
|
begin
|
22
|
-
puts ">>>>>> itg_sec - include it....."
|
22
|
+
# puts ">>>>>> itg_sec - include it....."
|
23
23
|
unless Rails.env.test?
|
24
24
|
store_in database: DB_NAME, client: CLIENT_NAME
|
25
|
-
puts "[itg_sec] set db details: #{DB_NAME}, #{CLIENT_NAME}"
|
25
|
+
# puts "[itg_sec] set db details: #{DB_NAME}, #{CLIENT_NAME}"
|
26
26
|
end
|
27
|
-
self.itg_print_db_info
|
27
|
+
# self.itg_print_db_info
|
28
28
|
rescue NameError => e
|
29
29
|
# Ignored - Used only because the gem does not have the Rails initialized!
|
30
30
|
raise if e.message != "uninitialized constant Itg::Sec::Rails"
|
@@ -11,10 +11,20 @@ module Itg
|
|
11
11
|
field :code, type: String
|
12
12
|
field :name, type: String
|
13
13
|
field :descr, type: String
|
14
|
-
field :
|
14
|
+
field :db_name, type: String
|
15
|
+
field :db_client, type: String, default: "default"
|
15
16
|
|
16
17
|
validates_presence_of(:code, :name)
|
17
18
|
validates_uniqueness_of :code
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
[code, name, descr]
|
22
|
+
end
|
23
|
+
|
24
|
+
# def itg_print(header: nil, prefix: '', allow_nested: true)
|
25
|
+
# puts header if header
|
26
|
+
# puts "#{prefix}#{[attrs['name'] || attrs['descr'] || attrs['code']]}"
|
27
|
+
# end
|
18
28
|
end
|
19
29
|
end
|
20
30
|
end
|
@@ -19,8 +19,10 @@ module Itg
|
|
19
19
|
|
20
20
|
validates_presence_of :kind
|
21
21
|
validates_presence_of :attrs
|
22
|
+
validates_presence_of :context
|
22
23
|
|
23
|
-
belongs_to :owner, class_name: 'User'
|
24
|
+
# belongs_to :owner, class_name: 'User'
|
25
|
+
belongs_to :owner, class_name: User
|
24
26
|
|
25
27
|
def to_s
|
26
28
|
attrs['name'] || attrs['descr'] || attrs['code']
|
@@ -44,9 +44,9 @@ module Itg
|
|
44
44
|
|
45
45
|
field :email, type: String
|
46
46
|
# field :password_digest, type: String
|
47
|
-
field :db, type: String
|
47
|
+
# field :db, type: String
|
48
48
|
field :kind, type: String, default: 'user'
|
49
|
-
field :contexts, type: Object, default: {}
|
49
|
+
# field :contexts, type: Object, default: {}
|
50
50
|
|
51
51
|
index({ email: 1 }, { unique: true, name: 'email_index' })
|
52
52
|
|
@@ -67,19 +67,20 @@ module Itg
|
|
67
67
|
super
|
68
68
|
end
|
69
69
|
|
70
|
-
def add_context(context, role: :user)
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
end
|
70
|
+
# def add_context(context, role: :user)
|
71
|
+
# if context.persisted?
|
72
|
+
# unless contexts.keys.include?(context.code.to_sym)
|
73
|
+
# contexts[context.code.to_sym] = {role: role.to_sym}
|
74
|
+
# contexts[context.code.to_sym][:name] = context[:name] if context[:name]
|
75
|
+
# contexts[context.code.to_sym][:descr] = context[:descr] if context[:descr]
|
76
|
+
# contexts[context.code.to_sym][:db] = context[:db] if context[:db]
|
77
|
+
# end
|
78
|
+
# end
|
79
|
+
# end
|
80
80
|
|
81
81
|
def to_s
|
82
|
-
attributes.symbolize_keys.slice(:_id, :email, :db, :role).to_s
|
82
|
+
# attributes.symbolize_keys.slice(:_id, :email, :db, :role).to_s
|
83
|
+
attributes.symbolize_keys.slice(:_id, :email, :role).to_s
|
83
84
|
end
|
84
85
|
|
85
86
|
def itg_print(header: nil, prefix: '', allow_nested: true)
|
data/lib/itg/version.rb
CHANGED
data/lib/itg.rb
CHANGED
@@ -10,9 +10,11 @@ require_relative "itg/itg_mongo_base"
|
|
10
10
|
require_relative "itg/itg_printable"
|
11
11
|
require_relative "itg/itg_api_key_authenticatable"
|
12
12
|
require_relative "itg/itg_response"
|
13
|
+
require_relative "itg/itg_current_base"
|
13
14
|
require_relative "itg/controllers/itg_generic_controller_base"
|
14
15
|
require_relative "itg/controllers/itg_api_keys_controller_base"
|
15
16
|
require_relative "itg/controllers/itg_entities_controller_base"
|
17
|
+
require_relative "itg/controllers/itg_controller_set_current_request_details"
|
16
18
|
require_relative "itg/itg_sec"
|
17
19
|
|
18
20
|
module Itg
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aAon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -30,9 +30,11 @@ files:
|
|
30
30
|
- itg.gemspec
|
31
31
|
- lib/itg.rb
|
32
32
|
- lib/itg/controllers/itg_api_keys_controller_base.rb
|
33
|
+
- lib/itg/controllers/itg_controller_set_current_request_details.rb
|
33
34
|
- lib/itg/controllers/itg_entities_controller_base.rb
|
34
35
|
- lib/itg/controllers/itg_generic_controller_base.rb
|
35
36
|
- lib/itg/itg_api_key_authenticatable.rb
|
37
|
+
- lib/itg/itg_current_base.rb
|
36
38
|
- lib/itg/itg_mongo_base.rb
|
37
39
|
- lib/itg/itg_printable.rb
|
38
40
|
- lib/itg/itg_response.rb
|