-
-
Save knzconnor/496568 to your computer and use it in GitHub Desktop.
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
#In case it wasn't obvious, this was a joke about Rails anti-patterns | |
def address(separator, seperator2=' ') | |
fields_array = %w(address1 address2 city state zip phone).map {|t| [:billing,t].join('_').to_sym} | |
(0..10).inject("") { |string, i| | |
if i.odd? | |
field = :separator | |
field = (field.to_s + '2').intern if i == 7 | |
else | |
field = fields_array[i/2] | |
end | |
temp = send(field) rescue nil | |
unless !temp.blank? | |
temp = eval "#{field.to_s}" rescue '' | |
temp = ' ' if temp == '' | |
end | |
string += temp.blank? ? string : string + temp | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment