Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename deep_merge to avoid conflicts with Rails #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
12 changes: 6 additions & 6 deletions lib/greensms/api/schema.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module GreenSMS
class ::Hash
def deep_merge(second)
def merge_deep(second)
merger = proc { |_, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : Array === v1 && Array === v2 ? v1 | v2 : [:undefined, nil, :nil].include?(v2) ? v1 : v2 }
merge(second.to_h, &merger)
end
Expand Down Expand Up @@ -70,7 +70,7 @@ def deep_merge(second)
},
},
"general" => {},
"voice" => common_schema.clone.deep_merge(
"voice" => common_schema.clone.merge_deep(
{
"v1" => {
"send" => {
Expand All @@ -92,7 +92,7 @@ def deep_merge(second)
},
}
),
"pay" => common_schema.clone.deep_merge({
"pay" => common_schema.clone.merge_deep({
"v1" => {
"send" => {
"type" => "object",
Expand All @@ -109,7 +109,7 @@ def deep_merge(second)
},
},
}),
"sms" => common_schema.clone.deep_merge(
"sms" => common_schema.clone.merge_deep(
{
"v1" => {
"send" => {
Expand All @@ -134,7 +134,7 @@ def deep_merge(second)
},
}
),
"viber" => common_schema.clone.deep_merge(
"viber" => common_schema.clone.merge_deep(
{
"v1" => {
"send" => {
Expand All @@ -157,7 +157,7 @@ def deep_merge(second)
},
}
),
"social" => common_schema.clone.deep_merge(
"social" => common_schema.clone.merge_deep(
{
"v1" => {
"send" => {
Expand Down