Skip to content

Instantly share code, notes, and snippets.

@joenoon
Created June 23, 2013 22:44
Show Gist options
  • Save joenoon/5846816 to your computer and use it in GitHub Desktop.
Save joenoon/5846816 to your computer and use it in GitHub Desktop.
YapModel, coming soon
class YapModel
def self.database
Dispatch.once { @database = YapDatabase.alloc.initWithPath(App.documents_path + "/yap.db") }
@database
end
def self.dbconnection
Thread.current["yap_dbconnection"] ||= WeakRef.new(new_dbconnection)
end
def self.new_dbconnection
YapModel.database.newConnection
end
attr_writer :dbconnection
def dbconnection
@dbconnection || self.class.dbconnection
end
# more to come, work in progress...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment