Created
May 28, 2012 17:22
-
-
Save jballanc/2820169 to your computer and use it in GitHub Desktop.
Prototype Ruby
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
class ORMConnection | |
attr_accessor :orm_driver | |
def connect | |
# do some stuff... | |
@orm_driver = some_driver | |
end | |
end | |
my_connection = ORMConnection.new.connect | |
class ORMObject < my_connection.singleton_class | |
def initialize(name) | |
@record_name = name | |
end | |
def get_records | |
# do some stuff... | |
@@orm_driver.fetch(@record_name, fetch_spec) | |
end | |
end | |
my_foo = ORMObject.new('foo') | |
my_bar = ORMObject.new('bar') | |
my_foo.get_records #=> collection of foos |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment