Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions lib/structured_params/params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,8 @@ def errors
end

# Convert structured objects to Hash and get attributes
#: (symbolize: true, compact: false) -> Hash[Symbol, untyped]
#: (symbolize: false, compact: false) -> Hash[String, untyped]
#: (symbolize: true, compact: true) -> Hash[Symbol, untyped]
#: (symbolize: false, compact: true) -> Hash[String, untyped]
#: (?symbolize: false, ?compact: bool) -> Hash[String, untyped]
#: (?symbolize: true, ?compact: bool) -> Hash[Symbol, untyped]
def attributes(symbolize: false, compact: false)
attrs = super()

Expand Down Expand Up @@ -154,8 +152,7 @@ def format_error_path(attr_name, index = nil)
end

# Serialize structured values
#: (bool, compact: false) -> untyped
#: (bool, compact: true) -> untyped
#: (bool, ?compact: bool) -> untyped
def serialize_structured_value(value, compact: false)
case value
when Array
Expand Down
18 changes: 6 additions & 12 deletions sig/structured_params/params.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,10 @@ module StructuredParams
def errors: () -> ::StructuredParams::Errors

# Convert structured objects to Hash and get attributes
# : (symbolize: true, compact: false) -> Hash[Symbol, untyped]
# : (symbolize: false, compact: false) -> Hash[String, untyped]
# : (symbolize: true, compact: true) -> Hash[Symbol, untyped]
# : (symbolize: false, compact: true) -> Hash[String, untyped]
def attributes: (symbolize: true, compact: false) -> Hash[Symbol, untyped]
| (symbolize: false, compact: false) -> Hash[String, untyped]
| (symbolize: true, compact: true) -> Hash[Symbol, untyped]
| (symbolize: false, compact: true) -> Hash[String, untyped]
# : (?symbolize: false, ?compact: bool) -> Hash[String, untyped]
# : (?symbolize: true, ?compact: bool) -> Hash[Symbol, untyped]
def attributes: (?symbolize: false, ?compact: bool) -> Hash[String, untyped]
| (?symbolize: true, ?compact: bool) -> Hash[Symbol, untyped]

private

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

# Serialize structured values
# : (bool, compact: false) -> untyped
# : (bool, compact: true) -> untyped
def serialize_structured_value: (bool, compact: false) -> untyped
| (bool, compact: true) -> untyped
# : (bool, ?compact: bool) -> untyped
def serialize_structured_value: (bool, ?compact: bool) -> untyped

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