Last active
October 26, 2018 23:58
-
-
Save beatmadsen/bf3d709a5aa7d5222abf8fe0cee0d7d2 to your computer and use it in GitHub Desktop.
Two methods instead of boolean parameter
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
# calling code: | |
age = user.belongs_to_system_a? ? | |
find_age_from_system_a(name: user.name) : | |
find_age_from_system_b(name: user.name) | |
# methods | |
def find_age_from_system_a(name:) | |
payload = build_payload(name) | |
response = call_system_a(payload) | |
parse(response) | |
end | |
def find_age_from_system_b(name:) | |
payload = build_payload(name) | |
response = call_system_b(payload) | |
parse(response) | |
end | |
private | |
def build_payload(name) | |
... | |
end | |
def parse(response) | |
... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment