Skip to content

Commit

Permalink
fix cops
Browse files Browse the repository at this point in the history
  • Loading branch information
npezza93 committed Oct 23, 2024
1 parent 695187e commit 6667b15
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions lib/webauthn/camelize.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
module WebAuthn::Camelize
def deep_camelize_keys(object)
if object.is_a?(Hash)
object.each_with_object(Hash.new) do |(key, value), result|
result[camelize(key)] = deep_camelize_keys(value)
# frozen_string_literal: true

module WebAuthn
module Camelize
def deep_camelize_keys(object)
if object.is_a?(Hash)
object.each_with_object({}) do |(key, value), result|
result[camelize(key)] = deep_camelize_keys(value)
end
else
object
end
else
object
end
end

def camelize(term)
term.to_s.
sub(/^(?:(?-mix:(?=a)b)(?=\b|[A-Z_])|\w)/) { |match| match.downcase }.
gsub(/(?:_|(\/))([a-z\d]*)/i) do
def camelize(term)
term.to_s
.sub(/^(?:(?-mix:(?=a)b)(?=\b|[A-Z_])|\w)/) { |match| match.downcase }
.gsub(/(?:_|(\/))([a-z\d]*)/i) do
$2.capitalize
end.to_sym
end
end
end

0 comments on commit 6667b15

Please sign in to comment.