Skip to content

Commit c71bae0

Browse files
committed
Update attributes method signatures to use optional keyword arguments in params.rb and params.rbs
1 parent 88078ae commit c71bae0

2 files changed

Lines changed: 9 additions & 18 deletions

File tree

lib/structured_params/params.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,8 @@ def errors
7373
end
7474

7575
# Convert structured objects to Hash and get attributes
76-
#: (symbolize: true, compact: false) -> Hash[Symbol, untyped]
77-
#: (symbolize: false, compact: false) -> Hash[String, untyped]
78-
#: (symbolize: true, compact: true) -> Hash[Symbol, untyped]
79-
#: (symbolize: false, compact: true) -> Hash[String, untyped]
76+
#: (?symbolize: false, ?compact: bool) -> Hash[String, untyped]
77+
#: (?symbolize: true, ?compact: bool) -> Hash[Symbol, untyped]
8078
def attributes(symbolize: false, compact: false)
8179
attrs = super()
8280

@@ -154,8 +152,7 @@ def format_error_path(attr_name, index = nil)
154152
end
155153

156154
# Serialize structured values
157-
#: (bool, compact: false) -> untyped
158-
#: (bool, compact: true) -> untyped
155+
#: (bool, ?compact: bool) -> untyped
159156
def serialize_structured_value(value, compact: false)
160157
case value
161158
when Array

sig/structured_params/params.rbs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,10 @@ module StructuredParams
3838
def errors: () -> ::StructuredParams::Errors
3939

4040
# Convert structured objects to Hash and get attributes
41-
# : (symbolize: true, compact: false) -> Hash[Symbol, untyped]
42-
# : (symbolize: false, compact: false) -> Hash[String, untyped]
43-
# : (symbolize: true, compact: true) -> Hash[Symbol, untyped]
44-
# : (symbolize: false, compact: true) -> Hash[String, untyped]
45-
def attributes: (symbolize: true, compact: false) -> Hash[Symbol, untyped]
46-
| (symbolize: false, compact: false) -> Hash[String, untyped]
47-
| (symbolize: true, compact: true) -> Hash[Symbol, untyped]
48-
| (symbolize: false, compact: true) -> Hash[String, untyped]
41+
# : (?symbolize: false, ?compact: bool) -> Hash[String, untyped]
42+
# : (?symbolize: true, ?compact: bool) -> Hash[Symbol, untyped]
43+
def attributes: (?symbolize: false, ?compact: bool) -> Hash[String, untyped]
44+
| (?symbolize: true, ?compact: bool) -> Hash[Symbol, untyped]
4945

5046
private
5147

@@ -74,10 +70,8 @@ module StructuredParams
7470
def format_error_path: (Symbol, Integer?) -> String
7571

7672
# Serialize structured values
77-
# : (bool, compact: false) -> untyped
78-
# : (bool, compact: true) -> untyped
79-
def serialize_structured_value: (bool, compact: false) -> untyped
80-
| (bool, compact: true) -> untyped
73+
# : (bool, ?compact: bool) -> untyped
74+
def serialize_structured_value: (bool, ?compact: bool) -> untyped
8175

8276
# Integrate structured parameter errors into parent errors
8377
# : (untyped, String) -> void

0 commit comments

Comments
 (0)