Skip to content

Instantly share code, notes, and snippets.

@beatmadsen
Last active October 26, 2018 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beatmadsen/bf3d709a5aa7d5222abf8fe0cee0d7d2 to your computer and use it in GitHub Desktop.
Save beatmadsen/bf3d709a5aa7d5222abf8fe0cee0d7d2 to your computer and use it in GitHub Desktop.
Two methods instead of boolean parameter
# 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