identikey 0.5.1 → 0.5.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b55edf8d9a08412a4ce162b70b130f149a0ea1047c97a14a301056aa5c41350
4
- data.tar.gz: eac60565c851f0ee3d100171a804d60e5804bb59539ad83b81c09d92b0a811f8
3
+ metadata.gz: 39bb043b3ece2e37fc84ec06bb4f83b88be7af8391fb2061bee01d64fc9f0464
4
+ data.tar.gz: 94114e6c78ce9572c80b415be3a27bb39e17eb57e978fcb1a446da4a63fc1d00
5
5
  SHA512:
6
- metadata.gz: bdcc16f8fa44bc513e44b6ed6b2ef5c3259cdc251568e2719a410306b033c27a1cc7542f19707ce1ae4803b6d1a7b0466a549f1a7a1ef93812c3e6bf70f26160
7
- data.tar.gz: f55cbd706367e52d32394c4e220146fec6ea0a0a881c3871d71a186b0857a58ecb19357e54837a67950b25647ad45a6125cdc7bf1f96ad83870734957e6f7394
6
+ metadata.gz: 43194c6c964d57d6565ccd01d5b714ad4f61ae9658d24c3798b240715b543e67378f1e44ade48c3d76af245072bb7704399b80763934a4a8141b444806288b76
7
+ data.tar.gz: 3aa8e78fc6d9b07b1d308b28cfaa4da4ede847dd33af3311a2db2f699ed9521720ec5d88485286be66f2c71aaf4f6b0bc276fd92b32e7e4df976064fb9ca9a83
@@ -61,12 +61,7 @@ module Identikey
61
61
  # `log:` keyword is set to false.
62
62
  #
63
63
  def ping(session_id:, log:)
64
- old_log = client.globals[:log]
65
- client.globals[:log] = log
66
-
67
- sessionalive(session_id: session_id)
68
- ensure
69
- client.globals[:log] = old_log
64
+ logging_to(log) { sessionalive(session_id: session_id) }
70
65
  end
71
66
 
72
67
  def admin_session_query(session_id:)
@@ -151,16 +146,23 @@ module Identikey
151
146
  end
152
147
 
153
148
 
154
- def user_query(session_id:, attributes:, query_options:)
155
- resp = super(message: {
156
- sessionID: session_id,
157
- attributeSet: {
158
- attributes: typed_attributes_query_list_from(attributes)
159
- },
160
- queryOptions: query_options
161
- })
162
-
163
- parse_response resp, :user_query_response
149
+ # Executes a userQuery command that searches users. By default, it doesn't
150
+ # log anywhere. To enable logging to a specific destination, pass a logger
151
+ # as the log: option. To log to the default destination, pass `true` as
152
+ # the log: option.
153
+ #
154
+ def user_query(session_id:, attributes:, query_options:, log: false)
155
+ logging_to(log) do
156
+ resp = super(message: {
157
+ sessionID: session_id,
158
+ attributeSet: {
159
+ attributes: typed_attributes_query_list_from(attributes)
160
+ },
161
+ queryOptions: query_options
162
+ })
163
+
164
+ parse_response resp, :user_query_response
165
+ end
164
166
  end
165
167
 
166
168
 
@@ -260,5 +262,24 @@ module Identikey
260
262
  )
261
263
  end
262
264
 
265
+ private
266
+ # Allows temporarily overriding the log destination. If it
267
+ # is set to `false` then logging is disabled altogether.
268
+ # If it is set to `true`, then this is a no-op.
269
+ #
270
+ def logging_to(destination)
271
+ old_log = client.globals[:log]
272
+
273
+ unless destination === true
274
+ client.globals[:log] = destination
275
+ end
276
+
277
+ yield
278
+
279
+ ensure
280
+ client.globals[:log] = old_log
281
+ end
282
+
283
+
263
284
  end
264
285
  end
@@ -1,3 +1,3 @@
1
1
  module Identikey
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: identikey
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcello Barnaba
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-01 00:00:00.000000000 Z
11
+ date: 2019-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: savon