-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove unused Hash#symbol_keys * Don't override Hash#stringify_keys from ActiveSupport * Don't pollute Object class * Add frozen_string_literal
- Loading branch information
Showing
6 changed files
with
38 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,35 @@ | ||
class ::Hash | ||
# via https://stackoverflow.com/a/25835016/2257038 | ||
def stringify_keys | ||
h = self.map do |k, v| | ||
v_str = if v.instance_of? Hash | ||
v.stringify_keys | ||
else | ||
v | ||
end | ||
# frozen_string_literal: true | ||
|
||
[k.to_s, v_str] | ||
unless Hash.method_defined?(:stringify_keys) | ||
class Hash | ||
# via https://stackoverflow.com/a/25835016/2257038 | ||
def stringify_keys | ||
h = self.map do |k, v| | ||
v_str = if v.instance_of? Hash | ||
v.stringify_keys | ||
else | ||
v | ||
end | ||
|
||
[k.to_s, v_str] | ||
end | ||
Hash[h] | ||
end | ||
Hash[h] | ||
end | ||
end | ||
|
||
# via https://stackoverflow.com/a/25835016/2257038 | ||
def symbol_keys | ||
h = self.map do |k, v| | ||
v_sym = if v.instance_of? Hash | ||
v.symbol_keys | ||
else | ||
v | ||
end | ||
|
||
[k.to_sym, v_sym] | ||
module LiveKit | ||
module Utils | ||
def to_http_url(url) | ||
if url.start_with?("ws") | ||
# replace ws prefix to http | ||
return url.sub(/^ws/, "http") | ||
else | ||
return url | ||
end | ||
end | ||
Hash[h] | ||
|
||
module_function :to_http_url | ||
end | ||
end | ||
|
||
# convert websocket urls to http | ||
def to_http_url(url) | ||
if url.start_with?("ws") | ||
# replace ws prefix to http | ||
return url.sub(/^ws/, "http") | ||
else | ||
return url | ||
end | ||
end |