Skip to content

Commit ca6b53d

Browse files
committed
fix set_valie for condition
1 parent ffa1ec1 commit ca6b53d

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ GIT
88
PATH
99
remote: .
1010
specs:
11-
json_schema_form (0.12.0)
11+
json_schema_form (0.12.1)
1212
activesupport (~> 6)
1313
dry-schema (~> 1.10)
1414
json_schemer (= 0.2.17)

lib/jsf/forms/condition.rb

+5-6
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,16 @@ def value
115115
dig('if', 'properties', condition_property_key, *path)
116116
end
117117

118-
# Sets a new value for the condition
118+
# Sets a new value for the condition_property_key
119119
#
120120
# @param [String, Boolean, Number] value
121121
# @param ['const', 'enum']
122122
#
123123
# @return [void]
124-
def set_value(value, condition_type: self.condition_type)
125-
dig('if', 'properties')&.clear
126-
127-
path = JSF::Forms::Form::CONDITION_TYPE_TO_PATH.call(condition_type)
128-
SuperHash::Utils.bury(self, 'if', 'properties', condition_property_key, *path, value)
124+
def set_value(value, key: condition_property_key, type: self.condition_type)
125+
dig('if', 'properties', key)&.clear
126+
path = JSF::Forms::Form::CONDITION_TYPE_TO_PATH.call(type)
127+
SuperHash::Utils.bury(self, 'if', 'properties', key, *path, value)
129128
end
130129

131130
# Takes a document or a part of a document (for nested hashes like JSF::Forms::Section) and

lib/jsf/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module JSF
2-
VERSION = "0.12.0"
2+
VERSION = "0.12.1"
33
end

test/spec/forms/condition_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ def test_set_value
126126
assert_equal 'not_const', instance.condition_type
127127
assert_equal 1, instance.value
128128

129-
instance.set_value(2, condition_type: 'enum')
129+
instance.set_value(2, type: 'enum')
130130
assert_equal false, instance.negated
131131
assert_equal 'enum', instance.condition_type
132132
assert_equal 2, instance.value
133133

134-
instance.set_value(3, condition_type: 'not_enum')
134+
instance.set_value(3, type: 'not_enum')
135135
assert_equal true, instance.negated
136136
assert_equal 'not_enum', instance.condition_type
137137
assert_equal 3, instance.value

0 commit comments

Comments
 (0)