Skip to content

Commit

Permalink
fix ruby 3.3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ezekg committed Jan 1, 2024
1 parent b2ac5d7 commit 905a40d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/typed_params/mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,20 @@ def self.call(*args, **kwargs, &block)
# │ 1 ││ 2 │ │ 5 │
# └───┘└───┘ └───┘
#
def depth_first_map(param, &)
def depth_first_map(param, &block)
return if param.nil?

# Postorder DFS, so we'll visit the children first.
if param.schema.children&.any?
case param.schema.children
in Array if param.array?
if param.schema.indexed?
param.schema.children.each_with_index { |v, i| self.class.call(param[i], schema: v, controller:, &) }
param.schema.children.each_with_index { |v, i| self.class.call(param[i], schema: v, controller:, &block) }
else
param.value.each { |v| self.class.call(v, schema: param.schema.children.first, controller:, &) }
param.value.each { |v| self.class.call(v, schema: param.schema.children.first, controller:, &block) }
end
in Hash if param.hash?
param.schema.children.each { |k, v| self.class.call(param[k], schema: v, controller:, &) }
param.schema.children.each { |k, v| self.class.call(param[k], schema: v, controller:, &block) }
else
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/typed_params/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def param(key, type:, **kwargs, &block)

##
# params defines multiple like-parameters for a hash schema.
def params(*keys, **kwargs, &) = keys.each { param(_1, **kwargs, &) }
def params(*keys, **kwargs, &block) = keys.each { param(_1, **kwargs, &block) }

##
# item defines an indexed parameter for an array schema.
Expand Down

0 comments on commit 905a40d

Please sign in to comment.