Created
August 24, 2009 19:40
-
-
Save jonathan/174097 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
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