Skip to content

Instantly share code, notes, and snippets.

@benhamill
Forked from kerinin/gist:4068172
Created November 13, 2012 20:34
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 benhamill/4068222 to your computer and use it in GitHub Desktop.
Save benhamill/4068222 to your computer and use it in GitHub Desktop.
Conditional organization
# Option 1
if eea_exists?
if eea_uses_something?
if eea_ever_used_application?
if eea_currently_uses_application?
recreate_eea; reactivate_application_for_eea; create_session; #13S
else
recreate_eea; reactivate_application_for_eea; create_session; #13S
end
else
recreate_eea; activate_application_for_eea; create_session; #9S
end
elsif eea_ever_used_application?
recreate_eea; reactivate_application_for_eea; create_session; #10S
else
recreate_eea; activate_application_for_eea; create_session; #11S
end
else
create_user_and_eea; activate_application_for_eea; create_session; #8S
end
# Option 2
if !eea_exists?
create_user_and_eea; activate_application_for_eea; create_session; #8S
elsif eea_exists? && !eea_uses_something? && !eea_ever_used_application?
recreate_eea; activate_application_for_eea; create_session; #11S
elsif eea_exists? && !eea_uses_something? && eea_ever_used_application?
recreate_eea; reactivate_application_for_eea; create_session; #10S
elsif eea_exists? && eea_uses_something? && !eea_ever_used_application?
recreate_eea; activate_application_for_eea; create_session; #9S
elsif eea_exists? && eea_uses_something? && eea_ever_used_application? && !eea_currently_uses_application?
recreate_eea; reactivate_application_for_eea; create_session; #13S
elsif eea_exists? && eea_uses_something? && eea_ever_used_application? && eea_currently_uses_application?
recreate_eea; create_session; #12S
end
def set_up
if eea_exists?
check_existing_user
else
# 8S
create_user_and_eea
activate_application_for_eea
create_session
end
end
def check_existing_user
if eea_uses_something?
check_existing_application_usage
else
check_not_existing_application_usage
end
end
def check_existing_application_usage
if eea_ever_used_application?
check_current_application_usage
else
# 9S
recreate_eea
activate_application_for_eea
create_session
end
end
def check_not_existing_application_usage
if eea_ever_used_application?
# 10S
recreate_eea
reactivate_application_for_eea
create_session
else
# 11S
recreate_eea
activate_application_for_eea
create_session
end
end
def check_current_application_usage
if eea_currently_uses_application?
# 12S
recreate_eea
create_session
else
# 13S
recreate_eea
reactivate_application_for_eea
create_session
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment