Skip to content

Commit 73820ab

Browse files
committed
Use fetch for consistently present fields to enforce validation
1 parent 204fe23 commit 73820ab

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lib/datadog/open_feature/binding/configuration.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def initialize(key:, value:)
7878

7979
def self.from_hash(variation_data)
8080
new(
81-
key: variation_data['key'],
82-
value: variation_data['value']
81+
key: variation_data.fetch('key'),
82+
value: variation_data.fetch('value')
8383
)
8484
end
8585
end
@@ -99,7 +99,7 @@ def initialize(key:, rules: nil, start_at: nil, end_at: nil, splits:, do_log: tr
9999

100100
def self.from_hash(allocation_data)
101101
new(
102-
key: allocation_data['key'],
102+
key: allocation_data.fetch('key'),
103103
rules: parse_rules(allocation_data['rules']),
104104
start_at: parse_timestamp(allocation_data['startAt']),
105105
end_at: parse_timestamp(allocation_data['endAt']),
@@ -148,7 +148,7 @@ def initialize(shards:, variation_key:, extra_logging: nil)
148148
def self.from_hash(split_data)
149149
new(
150150
shards: parse_shards(split_data.fetch('shards', [])),
151-
variation_key: split_data['variationKey'],
151+
variation_key: split_data.fetch('variationKey'),
152152
extra_logging: split_data.fetch('extraLogging', {})
153153
)
154154
end
@@ -172,8 +172,8 @@ def initialize(salt:, total_shards:, ranges:)
172172

173173
def self.from_hash(shard_data)
174174
new(
175-
salt: shard_data['salt'],
176-
total_shards: shard_data['totalShards'],
175+
salt: shard_data.fetch('salt'),
176+
total_shards: shard_data.fetch('totalShards'),
177177
ranges: parse_ranges(shard_data.fetch('ranges', []))
178178
)
179179
end
@@ -196,8 +196,8 @@ def initialize(start:, end_value:)
196196

197197
def self.from_hash(range_data)
198198
new(
199-
start: range_data['start'],
200-
end_value: range_data['end']
199+
start: range_data.fetch('start'),
200+
end_value: range_data.fetch('end')
201201
)
202202
end
203203

@@ -240,8 +240,8 @@ def initialize(attribute:, operator:, value:)
240240

241241
def self.from_hash(condition_data)
242242
new(
243-
attribute: condition_data['attribute'],
244-
operator: condition_data['operator'],
243+
attribute: condition_data.fetch('attribute'),
244+
operator: condition_data.fetch('operator'),
245245
value: parse_condition_value(condition_data['value'])
246246
)
247247
end

0 commit comments

Comments
 (0)