Skip to content

Instantly share code, notes, and snippets.

@jballanc
Created May 28, 2012 17:22
Show Gist options
  • Save jballanc/2820169 to your computer and use it in GitHub Desktop.
Save jballanc/2820169 to your computer and use it in GitHub Desktop.
Prototype Ruby
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