determinator 2.9.0 → 2.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7c5b0103e26f752c64d792674d30d854f7265f2a48ad3d546e4f2a758bb811a
4
- data.tar.gz: 99f0c278fd6b91fb1f20fcced167dcd8b70020b78d80be9803bc88ecdadfc7ae
3
+ metadata.gz: 227a75590dfa088f7096c65a51ab2d2950f9605ed3f29c7d62119df86e2c3721
4
+ data.tar.gz: 77c7e9ae41428c7e898f3dca7464d6987210379723bd8bc73906a8c73cbd62d2
5
5
  SHA512:
6
- metadata.gz: ed644f22e58a4d761eae0cff9d8f14b5ab257fd962d2d3bd5734679b38b5ba12d7dee61632710dbd0b116c0dd846ca2952b12ad0184252f8789b74a8fc62847b
7
- data.tar.gz: 78fd4b1d2de15e59fe1f417dc2703b37e643d8a08af493bcd1c4c51208493eab2fba82ab37b8b60af420b9d22e6402f4b570291a4d437d51172496ffd1e59e97
6
+ metadata.gz: 59fcec1ac83528e76f9ccdfb5985732d336fc6bb177055a4d5c02a4929f20c98b1a6052c96fa3397430c40d40733b4b8fb2fb801db041a3a125db64bd68276cf
7
+ data.tar.gz: dc73504e3e55e79d10a0939e3a32f16525523b8e480da280aae2a0400b578b3e04cb893ef593967767ffab88370ef118310d37b7df906cc48ea547dcb8570e91
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 2.9.1
2
+
3
+ Feature:
4
+ - Add `callback` argument to Control, allowing custom logic to notice the determination.
5
+
1
6
  # 2.9.0
2
7
 
3
8
  Feature:
@@ -72,6 +72,20 @@ module Determinator
72
72
  '#<Determinator::Control>'
73
73
  end
74
74
 
75
+ # Defines code that should execute when a determination is completed. This is particularly
76
+ # helpful for comparing determinations made by this control with other mechanisms.
77
+ #
78
+ # Please note that this block will be executed _synchronously_ before delivering the determination to the callsite.
79
+ #
80
+ # @yield [name, arguments, determination] Will be called when a determination was requested for the
81
+ # specified feature with `name`, with the given keyword arguments.
82
+ # @yieldparam name [String, nil] The name of the feature
83
+ # @yieldparam args [Hash] The keyword arguments passed to the determination method. This includes :id, :guid, :properties.
84
+ # @yieldparam determination [String,Boolean] The result of the determination
85
+ def on_determination(&block)
86
+ @determination_callback = block
87
+ end
88
+
75
89
  private
76
90
 
77
91
  Indicators = Struct.new(:rollout, :variant)
@@ -81,12 +95,15 @@ module Determinator
81
95
 
82
96
  if feature.nil? || feature.is_a?(ErrorResponse) || feature.is_a?(MissingResponse)
83
97
  Determinator.notice_missing_feature(name)
98
+ run_determination_callback(name, {id: id, guid: guid, properties: properties}, false)
84
99
  return false
85
100
  end
86
101
 
87
- determinate(feature, id: id, guid: guid, properties: properties).tap do |determination|
102
+ result = determinate(feature, id: id, guid: guid, properties: properties).tap do |determination|
88
103
  Determinator.notice_determination(id, guid, feature, determination)
89
104
  end
105
+ run_determination_callback(name, {id: id, guid: guid, properties: properties}, result)
106
+ result
90
107
  end
91
108
 
92
109
  def determinate(feature, id:, guid:, properties:)
@@ -320,5 +337,10 @@ module Determinator
320
337
  hash[name.to_s] = [*values].map(&:to_s)
321
338
  end
322
339
  end
340
+
341
+ def run_determination_callback(name, args, determination)
342
+ return unless @determination_callback
343
+ @determination_callback.call(name, args, determination)
344
+ end
323
345
  end
324
346
  end
@@ -1,3 +1,3 @@
1
1
  module Determinator
2
- VERSION = '2.9.0'
2
+ VERSION = '2.9.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: determinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.0
4
+ version: 2.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Hastings-Spital
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-26 00:00:00.000000000 Z
11
+ date: 2022-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday