Last active
December 24, 2015 12:49
-
-
Save jakeboxer/6800150 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # sinatra | |
| get "/:arg" do | |
| render my_database.send arg | |
| end | |
| def refactored_call_on_upcased_string(str, method_name) | |
| str.upcase.send(method_name) | |
| end | |
| def call_on_upcased_string(str, method_name) | |
| eval("str.upcase.#{method_name}") | |
| end | |
| call_on_upcased_string('jessica', 'reverse') | |
| # => "ACISSEJ" | |
| ### OLD CONTRIVED SHIT, IGNORE ### | |
| def hi_jessica(something) | |
| String_response = "you passed a string" | |
| Array_response = "you passed an array" | |
| eval("puts #{something.class.name}_response") | |
| end | |
| def refactored_hi_jessica(something) | |
| responses = { String => "you passed a string", Array => "you passed an array" } | |
| puts responses[something.class] | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment