Created
December 4, 2014 18:32
-
-
Save raorao/b7a0ff71235cff952016 to your computer and use it in GitHub Desktop.
Google Docs ORM spec
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
# all permissions/setup are handled through the google docs interface. basically, this isn’t a DSL for google docs. figure that shit out yourself. | |
# all querying logic happens in ruby. find is provided for simplicity. | |
# no optimizing for speed. this is a google doc db after all. | |
# connections only occur when necessary. no preloading. avoid unncessary connections after first. | |
# configuration must be simple. and preferably self-contained within file. | |
#not tied to language. would be cool to do this as a front-end JS library too. | |
class User < APIModel | |
def self.configure | |
@SPREADSHEET_URL = ‘someurl’ | |
@USERNAME = ### | |
@PASSWORD = ### | |
@AUTH_TOKEN = ### | |
end | |
end | |
# ruby methods that require DB connection. | |
User.all #[user] | |
User.find :id #user | |
user.reload #user | |
user.save #boolean | |
user.delete #boolean | |
# ruby methods with no DB connection. | |
user = User.new {foo: ‘bar’} #user | |
user.foo #bar | |
user.foo = ‘bas’ #baz | |
user.errors #array of errors | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment