Skip to content

Instantly share code, notes, and snippets.

@knzconnor
Forked from wilson/gist:496546
Created July 28, 2010 22:34
Show Gist options
  • Save knzconnor/496568 to your computer and use it in GitHub Desktop.
Save knzconnor/496568 to your computer and use it in GitHub Desktop.
#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