Skip to content

Commit 678ebde

Browse files
committed
Remove unnecessary parse_condition_value method and update RBS signatures
- Remove parse_condition_value method that returns input unchanged - Use condition_data.fetch('value') directly for cleaner code - Update RBS signatures: from_json → from_hash across all classes - Fix Flag parameter order in RBS: (flag_data, key) instead of (key, flag_data) - Remove parse_condition_value method signature from RBS
1 parent 18d1efc commit 678ebde

File tree

2 files changed

+10
-24
lines changed

2 files changed

+10
-24
lines changed

lib/datadog/open_feature/binding/configuration.rb

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -240,21 +240,10 @@ def self.from_hash(condition_data)
240240
new(
241241
attribute: condition_data.fetch('attribute'),
242242
operator: condition_data.fetch('operator'),
243-
value: parse_condition_value(condition_data['value'])
243+
value: condition_data.fetch('value')
244244
)
245245
end
246246

247-
private
248-
249-
def self.parse_condition_value(value_data)
250-
# Handle both single values and arrays for ONE_OF/NOT_ONE_OF operators
251-
case value_data
252-
when Array
253-
value_data
254-
else
255-
value_data
256-
end
257-
end
258247
end
259248

260249
# Main configuration container

sig/datadog/open_feature/binding/configuration.rbs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module Datadog
4242
allocations: ::Array[Allocation]
4343
) -> void
4444

45-
def self.from_json: (::String key, ::Hash[::String, untyped] flag_data) -> Flag
45+
def self.from_hash: (::Hash[::String, untyped] flag_data, ::String key) -> Flag
4646

4747
private
4848

@@ -57,7 +57,7 @@ module Datadog
5757

5858
def initialize: (key: ::String, value: untyped) -> void
5959

60-
def self.from_json: (::Hash[::String, untyped] variation_data) -> Variation
60+
def self.from_hash: (::Hash[::String, untyped] variation_data) -> Variation
6161
end
6262

6363
class Allocation
@@ -77,7 +77,7 @@ module Datadog
7777
?do_log: bool
7878
) -> void
7979

80-
def self.from_json: (::Hash[::String, untyped] allocation_data) -> Allocation
80+
def self.from_hash: (::Hash[::String, untyped] allocation_data) -> Allocation
8181

8282
private
8383

@@ -99,7 +99,7 @@ module Datadog
9999
?extra_logging: ::Hash[::String, untyped]?
100100
) -> void
101101

102-
def self.from_json: (::Hash[::String, untyped] split_data) -> Split
102+
def self.from_hash: (::Hash[::String, untyped] split_data) -> Split
103103

104104
private
105105

@@ -117,7 +117,7 @@ module Datadog
117117
ranges: ::Array[ShardRange]
118118
) -> void
119119

120-
def self.from_json: (::Hash[::String, untyped] shard_data) -> Shard
120+
def self.from_hash: (::Hash[::String, untyped] shard_data) -> Shard
121121

122122
private
123123

@@ -130,7 +130,7 @@ module Datadog
130130

131131
def initialize: (start: ::Integer, end_value: ::Integer) -> void
132132

133-
def self.from_json: (::Hash[::String, untyped] range_data) -> ShardRange
133+
def self.from_hash: (::Hash[::String, untyped] range_data) -> ShardRange
134134

135135
def end: () -> ::Integer
136136
end
@@ -140,7 +140,7 @@ module Datadog
140140

141141
def initialize: (conditions: ::Array[Condition]) -> void
142142

143-
def self.from_json: (::Hash[::String, untyped] rule_data) -> Rule
143+
def self.from_hash: (::Hash[::String, untyped] rule_data) -> Rule
144144

145145
private
146146

@@ -154,11 +154,8 @@ module Datadog
154154

155155
def initialize: (attribute: ::String, operator: ::String, value: untyped) -> void
156156

157-
def self.from_json: (::Hash[::String, untyped] condition_data) -> Condition
157+
def self.from_hash: (::Hash[::String, untyped] condition_data) -> Condition
158158

159-
private
160-
161-
def self.parse_condition_value: (untyped value_data) -> untyped
162159
end
163160

164161
class Configuration
@@ -167,7 +164,7 @@ module Datadog
167164

168165
def initialize: (flags: ::Hash[::String, Flag], ?schema_version: ::String?) -> void
169166

170-
def self.from_json: (::Hash[::String, untyped] config_data) -> Configuration
167+
def self.from_hash: (::Hash[::String, untyped] config_data) -> Configuration
171168

172169
def get_flag: (::String flag_key) -> Flag?
173170
end

0 commit comments

Comments
 (0)