Skip to content

Instantly share code, notes, and snippets.

@raorao
Created December 4, 2014 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raorao/b7a0ff71235cff952016 to your computer and use it in GitHub Desktop.
Save raorao/b7a0ff71235cff952016 to your computer and use it in GitHub Desktop.
Google Docs ORM spec
# 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