Skip to content

Instantly share code, notes, and snippets.

@jonathan
Created August 24, 2009 19:40
Show Gist options
  • Save jonathan/174097 to your computer and use it in GitHub Desktop.
Save jonathan/174097 to your computer and use it in GitHub Desktop.
module PrettyColumns
def run_stuff(sql)
result = ActiveRecord::Base.execute(sql)
order_columns(result)
end
def order_columns(result)
raise NotImplementedError
end
end
class MyClass < ActiveRecord::Base
include PrettyColumns
def order_columns(result)
my_results = []
my_results << result[:name]
my_results << result[:junk]
my_results << result[:stuff]
my_results
end
end
# c = MyClass.new
# <MyClass::MemStuff>
# c.run_stuff("this is a sql query")
# ["Name", "Junk", "Stuff"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment